@anydocs/core 1.0.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/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +1 -0
- package/dist/config/project-config.d.ts +10 -0
- package/dist/config/project-config.d.ts.map +1 -0
- package/dist/config/project-config.js +52 -0
- package/dist/errors/domain-error.d.ts +12 -0
- package/dist/errors/domain-error.d.ts.map +1 -0
- package/dist/errors/domain-error.js +8 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/validation-error.d.ts +5 -0
- package/dist/errors/validation-error.d.ts.map +1 -0
- package/dist/errors/validation-error.js +7 -0
- package/dist/fs/api-source-repository.d.ts +16 -0
- package/dist/fs/api-source-repository.d.ts.map +1 -0
- package/dist/fs/api-source-repository.js +89 -0
- package/dist/fs/content-repository.d.ts +13 -0
- package/dist/fs/content-repository.d.ts.map +1 -0
- package/dist/fs/content-repository.js +171 -0
- package/dist/fs/docs-repository.d.ts +26 -0
- package/dist/fs/docs-repository.d.ts.map +1 -0
- package/dist/fs/docs-repository.js +270 -0
- package/dist/fs/index.d.ts +5 -0
- package/dist/fs/index.d.ts.map +1 -0
- package/dist/fs/index.js +4 -0
- package/dist/fs/project-paths.d.ts +4 -0
- package/dist/fs/project-paths.d.ts.map +1 -0
- package/dist/fs/project-paths.js +55 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/publishing/build-artifacts.d.ts +4 -0
- package/dist/publishing/build-artifacts.d.ts.map +1 -0
- package/dist/publishing/build-artifacts.js +453 -0
- package/dist/publishing/build-openapi-artifacts.d.ts +3 -0
- package/dist/publishing/build-openapi-artifacts.d.ts.map +1 -0
- package/dist/publishing/build-openapi-artifacts.js +253 -0
- package/dist/publishing/index.d.ts +4 -0
- package/dist/publishing/index.d.ts.map +1 -0
- package/dist/publishing/index.js +3 -0
- package/dist/publishing/publication-filter.d.ts +22 -0
- package/dist/publishing/publication-filter.d.ts.map +1 -0
- package/dist/publishing/publication-filter.js +98 -0
- package/dist/schemas/api-source-schema.d.ts +3 -0
- package/dist/schemas/api-source-schema.d.ts.map +1 -0
- package/dist/schemas/api-source-schema.js +110 -0
- package/dist/schemas/docs-schema.d.ts +7 -0
- package/dist/schemas/docs-schema.d.ts.map +1 -0
- package/dist/schemas/docs-schema.js +212 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/project-schema.d.ts +3 -0
- package/dist/schemas/project-schema.d.ts.map +1 -0
- package/dist/schemas/project-schema.js +268 -0
- package/dist/services/authoring-service.d.ts +137 -0
- package/dist/services/authoring-service.d.ts.map +1 -0
- package/dist/services/authoring-service.js +583 -0
- package/dist/services/build-service.d.ts +35 -0
- package/dist/services/build-service.d.ts.map +1 -0
- package/dist/services/build-service.js +84 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +10 -0
- package/dist/services/init-service.d.ts +15 -0
- package/dist/services/init-service.d.ts.map +1 -0
- package/dist/services/init-service.js +127 -0
- package/dist/services/legacy-conversion-service.d.ts +8 -0
- package/dist/services/legacy-conversion-service.d.ts.map +1 -0
- package/dist/services/legacy-conversion-service.js +601 -0
- package/dist/services/legacy-import-service.d.ts +10 -0
- package/dist/services/legacy-import-service.d.ts.map +1 -0
- package/dist/services/legacy-import-service.js +239 -0
- package/dist/services/page-template-service.d.ts +81 -0
- package/dist/services/page-template-service.d.ts.map +1 -0
- package/dist/services/page-template-service.js +342 -0
- package/dist/services/preview-service.d.ts +29 -0
- package/dist/services/preview-service.d.ts.map +1 -0
- package/dist/services/preview-service.js +45 -0
- package/dist/services/watch-service.d.ts +24 -0
- package/dist/services/watch-service.d.ts.map +1 -0
- package/dist/services/watch-service.js +216 -0
- package/dist/services/web-runtime-bridge.d.ts +33 -0
- package/dist/services/web-runtime-bridge.d.ts.map +1 -0
- package/dist/services/web-runtime-bridge.js +330 -0
- package/dist/services/workflow-compatibility-service.d.ts +3 -0
- package/dist/services/workflow-compatibility-service.d.ts.map +1 -0
- package/dist/services/workflow-compatibility-service.js +53 -0
- package/dist/services/workflow-standard-service.d.ts +9 -0
- package/dist/services/workflow-standard-service.d.ts.map +1 -0
- package/dist/services/workflow-standard-service.js +372 -0
- package/dist/types/api-source.d.ts +34 -0
- package/dist/types/api-source.d.ts.map +1 -0
- package/dist/types/api-source.js +8 -0
- package/dist/types/docs.d.ts +65 -0
- package/dist/types/docs.d.ts.map +1 -0
- package/dist/types/docs.js +8 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/legacy-import.d.ts +72 -0
- package/dist/types/legacy-import.d.ts.map +1 -0
- package/dist/types/legacy-import.js +1 -0
- package/dist/types/project.d.ts +85 -0
- package/dist/types/project.d.ts.map +1 -0
- package/dist/types/project.js +5 -0
- package/dist/types/workflow-standard.d.ts +51 -0
- package/dist/types/workflow-standard.d.ts.map +1 -0
- package/dist/types/workflow-standard.js +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/slug.d.ts +3 -0
- package/dist/utils/slug.d.ts.map +1 -0
- package/dist/utils/slug.js +21 -0
- package/dist/utils/yoopta-content.d.ts +13 -0
- package/dist/utils/yoopta-content.d.ts.map +1 -0
- package/dist/utils/yoopta-content.js +73 -0
- package/dist/utils/yoopta-render.d.ts +7 -0
- package/dist/utils/yoopta-render.d.ts.map +1 -0
- package/dist/utils/yoopta-render.js +155 -0
- package/package.json +30 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type DocsLang } from './docs.ts';
|
|
2
|
+
export declare const SUPPORTED_DOCS_LANGUAGES: readonly ["zh", "en"];
|
|
3
|
+
export declare const DEFAULT_DOCS_THEME_ID = "classic-docs";
|
|
4
|
+
export declare const SUPPORTED_DOCS_CODE_THEMES: readonly ["github-light", "github-dark"];
|
|
5
|
+
export declare const DEFAULT_DOCS_CODE_THEME = "github-dark";
|
|
6
|
+
export type DocsLanguage = DocsLang;
|
|
7
|
+
export type DocsCodeTheme = (typeof SUPPORTED_DOCS_CODE_THEMES)[number];
|
|
8
|
+
export type ProjectSiteThemeBranding = {
|
|
9
|
+
siteTitle?: string;
|
|
10
|
+
homeLabel?: string;
|
|
11
|
+
logoSrc?: string;
|
|
12
|
+
logoAlt?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ProjectSiteThemeChrome = {
|
|
15
|
+
showSearch?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type ProjectSiteThemeColors = {
|
|
18
|
+
primary?: string;
|
|
19
|
+
primaryForeground?: string;
|
|
20
|
+
accent?: string;
|
|
21
|
+
accentForeground?: string;
|
|
22
|
+
sidebarActive?: string;
|
|
23
|
+
sidebarActiveForeground?: string;
|
|
24
|
+
};
|
|
25
|
+
export type ProjectSiteTheme = {
|
|
26
|
+
id: string;
|
|
27
|
+
branding?: ProjectSiteThemeBranding;
|
|
28
|
+
chrome?: ProjectSiteThemeChrome;
|
|
29
|
+
colors?: ProjectSiteThemeColors;
|
|
30
|
+
codeTheme?: DocsCodeTheme;
|
|
31
|
+
};
|
|
32
|
+
export type ProjectSiteTopNavLabel = string | Partial<Record<DocsLanguage, string>>;
|
|
33
|
+
export type ProjectSiteTopNavItem = {
|
|
34
|
+
id: string;
|
|
35
|
+
type: 'nav-group';
|
|
36
|
+
groupId: string;
|
|
37
|
+
label: ProjectSiteTopNavLabel;
|
|
38
|
+
} | {
|
|
39
|
+
id: string;
|
|
40
|
+
type: 'external';
|
|
41
|
+
href: string;
|
|
42
|
+
openInNewTab?: boolean;
|
|
43
|
+
label: ProjectSiteTopNavLabel;
|
|
44
|
+
};
|
|
45
|
+
export type ProjectSiteNavigation = {
|
|
46
|
+
topNav?: ProjectSiteTopNavItem[];
|
|
47
|
+
};
|
|
48
|
+
export type ProjectSiteConfig = {
|
|
49
|
+
theme: ProjectSiteTheme;
|
|
50
|
+
navigation?: ProjectSiteNavigation;
|
|
51
|
+
};
|
|
52
|
+
export type ProjectConfig = {
|
|
53
|
+
version: 1;
|
|
54
|
+
projectId: string;
|
|
55
|
+
name: string;
|
|
56
|
+
defaultLanguage: DocsLanguage;
|
|
57
|
+
languages: DocsLanguage[];
|
|
58
|
+
site: ProjectSiteConfig;
|
|
59
|
+
build?: {
|
|
60
|
+
outputDir?: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type ProjectPathContract = {
|
|
64
|
+
repoRoot: string;
|
|
65
|
+
projectRoot: string;
|
|
66
|
+
configFile: string;
|
|
67
|
+
workflowFile: string;
|
|
68
|
+
importsRoot: string;
|
|
69
|
+
apiSourcesRoot: string;
|
|
70
|
+
pagesRoot: string;
|
|
71
|
+
navigationRoot: string;
|
|
72
|
+
artifactRoot: string;
|
|
73
|
+
llmsFile: string;
|
|
74
|
+
machineReadableRoot: string;
|
|
75
|
+
languageRoots: Record<DocsLanguage, {
|
|
76
|
+
pagesDir: string;
|
|
77
|
+
navigationFile: string;
|
|
78
|
+
searchIndexFile: string;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
81
|
+
export type ProjectContract = {
|
|
82
|
+
config: ProjectConfig;
|
|
83
|
+
paths: ProjectPathContract;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/types/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1D,eAAO,MAAM,wBAAwB,uBAAiB,CAAC;AACvD,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD,eAAO,MA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AG;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DOCS_LANGUAGES } from "./docs.js";
|
|
2
|
+
export const SUPPORTED_DOCS_LANGUAGES = DOCS_LANGUAGES;
|
|
3
|
+
export const DEFAULT_DOCS_THEME_ID = 'classic-docs';
|
|
4
|
+
export const SUPPORTED_DOCS_CODE_THEMES = ['github-light', 'github-dark'];
|
|
5
|
+
export const DEFAULT_DOCS_CODE_THEME = 'github-dark';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PageStatus } from './docs.ts';
|
|
2
|
+
import type { DocsLanguage, ProjectContract } from './project.ts';
|
|
3
|
+
export type WorkflowStandardFile = {
|
|
4
|
+
id: 'projectConfig' | 'workflowStandard' | 'navigation' | 'page' | 'apiSource' | 'llms' | 'llmsFull' | 'machineReadableRoot' | 'machineReadableIndex' | 'openApiRoot' | 'openApiIndex' | 'searchIndex' | 'chunkIndex';
|
|
5
|
+
path: string;
|
|
6
|
+
format: 'json' | 'text' | 'directory';
|
|
7
|
+
required: boolean;
|
|
8
|
+
writable: boolean;
|
|
9
|
+
generated: boolean;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
export type WorkflowStandardStep = 'loadConfig' | 'loadContent' | 'validate' | 'persistSources' | 'filterPublished' | 'generateArtifacts' | 'reportResult';
|
|
13
|
+
export type WorkflowStandardDefinition = {
|
|
14
|
+
version: 1;
|
|
15
|
+
standardId: 'anydocs-phase-1';
|
|
16
|
+
projectContractVersion: ProjectContract['config']['version'];
|
|
17
|
+
localFirst: true;
|
|
18
|
+
uiIndependent: true;
|
|
19
|
+
supportedLanguages: DocsLanguage[];
|
|
20
|
+
enabledLanguages: DocsLanguage[];
|
|
21
|
+
publicationStatuses: PageStatus[];
|
|
22
|
+
publishedStatuses: Extract<PageStatus, 'published'>[];
|
|
23
|
+
sourceFiles: WorkflowStandardFile[];
|
|
24
|
+
generatedArtifacts: WorkflowStandardFile[];
|
|
25
|
+
contentModel: {
|
|
26
|
+
projectConfigFields: Array<keyof ProjectContract['config']>;
|
|
27
|
+
pageRequiredFields: string[];
|
|
28
|
+
pageOptionalFields: string[];
|
|
29
|
+
navigationRequiredFields: string[];
|
|
30
|
+
};
|
|
31
|
+
orchestration: {
|
|
32
|
+
workflowSteps: WorkflowStandardStep[];
|
|
33
|
+
publicationRule: 'published-only';
|
|
34
|
+
futureCompatibleWithoutReinitialization: true;
|
|
35
|
+
externalAutomationReady: true;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type WorkflowStandardExport = {
|
|
39
|
+
definition: WorkflowStandardDefinition;
|
|
40
|
+
markdownGuide: string;
|
|
41
|
+
};
|
|
42
|
+
export type WorkflowCompatibilityAssessment = {
|
|
43
|
+
compatible: true;
|
|
44
|
+
standardId: WorkflowStandardDefinition['standardId'];
|
|
45
|
+
projectContractVersion: WorkflowStandardDefinition['projectContractVersion'];
|
|
46
|
+
reusableAcrossProjects: true;
|
|
47
|
+
futureCompatibleWithoutReinitialization: true;
|
|
48
|
+
externalAutomationReady: true;
|
|
49
|
+
validatedAt: string;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=workflow-standard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-standard.d.ts","sourceRoot":"","sources":["../../src/types/workflow-standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EACE,eAAe,GACf,kBAAkB,GAClB,YAAY,GACZ,MAAM,GACN,WAAW,GACX,MAAM,GACN,UAAU,GACV,qBAAqB,GACrB,sBAAsB,GACtB,aAAa,GACb,cAAc,GACd,aAAa,GACb,Y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C;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,0BAA0B,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,0BAA0B,CAAC,YAAY,CAAC,CAAC;IACrD,sBAAsB,EAAE,0BAA0B,CAAC,wBAAwB,CAAC,CAAC;IAC7E,sBAAsB,EAAE,IAAI,CAAC;IAC7B,uCAAuC,EAAE,IAAI,CAAC;IAC9C,uBAAuB,EAAE,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../src/utils/slug.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAQ9D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAStD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ValidationError } from "../errors/validation-error.js";
|
|
2
|
+
export function normalizeSlug(slug) {
|
|
3
|
+
if (!slug)
|
|
4
|
+
return '';
|
|
5
|
+
const raw = Array.isArray(slug) ? slug.join('/') : slug;
|
|
6
|
+
return raw
|
|
7
|
+
.split('/')
|
|
8
|
+
.map((segment) => segment.trim())
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.join('/');
|
|
11
|
+
}
|
|
12
|
+
export function assertValidPageId(pageId) {
|
|
13
|
+
if (!pageId || pageId.includes('/') || pageId.includes('..')) {
|
|
14
|
+
throw new ValidationError(`Invalid page id "${pageId}".`, {
|
|
15
|
+
entity: 'page-doc',
|
|
16
|
+
rule: 'page-id-safe-filename',
|
|
17
|
+
remediation: 'Use a non-empty page id without path separators or parent-directory traversal.',
|
|
18
|
+
metadata: { pageId },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DOCS_YOOPTA_ALLOWED_TYPES: readonly ["Paragraph", "HeadingOne", "HeadingTwo", "HeadingThree", "BulletedList", "NumberedList", "TodoList", "Blockquote", "Code", "CodeGroup", "Divider", "Callout", "Image", "Table", "Link"];
|
|
2
|
+
export declare const DOCS_YOOPTA_ALLOWED_MARKS: readonly ["bold", "italic", "underline", "strike", "code"];
|
|
3
|
+
export declare const DOCS_YOOPTA_AUTHORING_GUIDANCE: readonly ["Prefer structured Yoopta blocks over empty content objects or markdown-only placeholders.", "Use HeadingTwo and HeadingThree to create meaningful section hierarchy for reader TOC extraction.", "Mix paragraphs with lists, callouts, code blocks, tables, images, and links when the source material warrants structure.", "Reserve HeadingOne for title-like leading content only; the reader already has the page title separately.", "Use CodeGroup when presenting the same example in multiple languages or package managers."];
|
|
4
|
+
type YooptaValidationResult = {
|
|
5
|
+
ok: true;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
error: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function validateYooptaContentValue(value: unknown): YooptaValidationResult;
|
|
11
|
+
export declare function assertValidYooptaContentValue(value: unknown): void;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=yoopta-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yoopta-content.d.ts","sourceRoot":"","sources":["../../src/utils/yoopta-content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,mMAgB5B,CAAC;AAEX,eAAO,MAAM,yBAAyB,4DAM5B,CAAC;AAEX,eAAO,MAAM,8BAA8B,mhBAMjC,CAAC;AAEX,KAAK,sBAAsB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAQ1E,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,CAwBjF;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAOlE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const DOCS_YOOPTA_ALLOWED_TYPES = [
|
|
2
|
+
'Paragraph',
|
|
3
|
+
'HeadingOne',
|
|
4
|
+
'HeadingTwo',
|
|
5
|
+
'HeadingThree',
|
|
6
|
+
'BulletedList',
|
|
7
|
+
'NumberedList',
|
|
8
|
+
'TodoList',
|
|
9
|
+
'Blockquote',
|
|
10
|
+
'Code',
|
|
11
|
+
'CodeGroup',
|
|
12
|
+
'Divider',
|
|
13
|
+
'Callout',
|
|
14
|
+
'Image',
|
|
15
|
+
'Table',
|
|
16
|
+
'Link',
|
|
17
|
+
];
|
|
18
|
+
export const DOCS_YOOPTA_ALLOWED_MARKS = [
|
|
19
|
+
'bold',
|
|
20
|
+
'italic',
|
|
21
|
+
'underline',
|
|
22
|
+
'strike',
|
|
23
|
+
'code',
|
|
24
|
+
];
|
|
25
|
+
export const DOCS_YOOPTA_AUTHORING_GUIDANCE = [
|
|
26
|
+
'Prefer structured Yoopta blocks over empty content objects or markdown-only placeholders.',
|
|
27
|
+
'Use HeadingTwo and HeadingThree to create meaningful section hierarchy for reader TOC extraction.',
|
|
28
|
+
'Mix paragraphs with lists, callouts, code blocks, tables, images, and links when the source material warrants structure.',
|
|
29
|
+
'Reserve HeadingOne for title-like leading content only; the reader already has the page title separately.',
|
|
30
|
+
'Use CodeGroup when presenting the same example in multiple languages or package managers.',
|
|
31
|
+
];
|
|
32
|
+
function isRecord(x) {
|
|
33
|
+
return !!x && typeof x === 'object' && !Array.isArray(x);
|
|
34
|
+
}
|
|
35
|
+
const allowedTypeSet = new Set(DOCS_YOOPTA_ALLOWED_TYPES);
|
|
36
|
+
export function validateYooptaContentValue(value) {
|
|
37
|
+
if (value == null)
|
|
38
|
+
return { ok: true };
|
|
39
|
+
if (!isRecord(value))
|
|
40
|
+
return { ok: false, error: 'content must be an object' };
|
|
41
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
42
|
+
if (!isRecord(raw))
|
|
43
|
+
return { ok: false, error: `content.${key} must be an object` };
|
|
44
|
+
const type = raw.type;
|
|
45
|
+
const id = raw.id;
|
|
46
|
+
const blockValue = raw.value;
|
|
47
|
+
if (typeof type !== 'string')
|
|
48
|
+
return { ok: false, error: `content.${key}.type must be a string` };
|
|
49
|
+
if (!allowedTypeSet.has(type))
|
|
50
|
+
return { ok: false, error: `content contains disallowed block type: ${type}` };
|
|
51
|
+
if (typeof id !== 'string')
|
|
52
|
+
return { ok: false, error: `content.${key}.id must be a string` };
|
|
53
|
+
if (!Array.isArray(blockValue))
|
|
54
|
+
return { ok: false, error: `content.${key}.value must be an array` };
|
|
55
|
+
const meta = raw.meta;
|
|
56
|
+
if (meta != null) {
|
|
57
|
+
if (!isRecord(meta))
|
|
58
|
+
return { ok: false, error: `content.${key}.meta must be an object` };
|
|
59
|
+
if (typeof meta.order !== 'number')
|
|
60
|
+
return { ok: false, error: `content.${key}.meta.order must be a number` };
|
|
61
|
+
if (typeof meta.depth !== 'number')
|
|
62
|
+
return { ok: false, error: `content.${key}.meta.depth must be a number` };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { ok: true };
|
|
66
|
+
}
|
|
67
|
+
export function assertValidYooptaContentValue(value) {
|
|
68
|
+
const result = validateYooptaContentValue(value);
|
|
69
|
+
if (result.ok) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
throw new Error(result.error);
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yoopta-render.d.ts","sourceRoot":"","sources":["../../src/utils/yoopta-render.ts"],"names":[],"mappings":"AAEA,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA0KF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAiBtE"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { assertValidYooptaContentValue } from "./yoopta-content.js";
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function extractText(value) {
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return value.map(extractText).join('');
|
|
11
|
+
}
|
|
12
|
+
if (!isRecord(value)) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
if (typeof value.text === 'string') {
|
|
16
|
+
return value.text;
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(value.value)) {
|
|
19
|
+
return value.value.map(extractText).join('');
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value.children)) {
|
|
22
|
+
return value.children.map(extractText).join('');
|
|
23
|
+
}
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
function normalizeWhitespace(value) {
|
|
27
|
+
return value.replace(/\s+/g, ' ').trim();
|
|
28
|
+
}
|
|
29
|
+
function getBlockOrder(value) {
|
|
30
|
+
if (!isRecord(value) || !isRecord(value.meta) || typeof value.meta.order !== 'number') {
|
|
31
|
+
return Number.POSITIVE_INFINITY;
|
|
32
|
+
}
|
|
33
|
+
return value.meta.order;
|
|
34
|
+
}
|
|
35
|
+
function getFirstValueEntry(block) {
|
|
36
|
+
if (!isRecord(block) || !Array.isArray(block.value)) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const entry = block.value[0];
|
|
40
|
+
return isRecord(entry) ? entry : null;
|
|
41
|
+
}
|
|
42
|
+
function getStringProp(value, key) {
|
|
43
|
+
if (!isRecord(value) || !isRecord(value.props) || typeof value.props[key] !== 'string') {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return value.props[key];
|
|
47
|
+
}
|
|
48
|
+
function getBooleanProp(value, key) {
|
|
49
|
+
if (!isRecord(value) || !isRecord(value.props) || typeof value.props[key] !== 'boolean') {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return value.props[key];
|
|
53
|
+
}
|
|
54
|
+
function renderCodeGroupMarkdown(blockEntry) {
|
|
55
|
+
if (!Array.isArray(blockEntry.children)) {
|
|
56
|
+
return '```text\n\n```';
|
|
57
|
+
}
|
|
58
|
+
const rendered = blockEntry.children
|
|
59
|
+
.filter(isRecord)
|
|
60
|
+
.map((child) => {
|
|
61
|
+
const title = getStringProp(child, 'title');
|
|
62
|
+
const language = getStringProp(child, 'language') ?? '';
|
|
63
|
+
const code = extractText(child.children ?? []).trim();
|
|
64
|
+
const heading = title ? `#### ${title}\n\n` : '';
|
|
65
|
+
return `${heading}\`\`\`${language}\n${code}\n\`\`\``;
|
|
66
|
+
})
|
|
67
|
+
.filter(Boolean);
|
|
68
|
+
return rendered.join('\n\n');
|
|
69
|
+
}
|
|
70
|
+
function renderTableMarkdown(blockEntry) {
|
|
71
|
+
if (!Array.isArray(blockEntry.children)) {
|
|
72
|
+
return '| |\n| --- |\n| |';
|
|
73
|
+
}
|
|
74
|
+
const rows = blockEntry.children
|
|
75
|
+
.filter(isRecord)
|
|
76
|
+
.map((row) => Array.isArray(row.children)
|
|
77
|
+
? row.children
|
|
78
|
+
.filter(isRecord)
|
|
79
|
+
.map((cell) => normalizeWhitespace(extractText(cell.children ?? [])))
|
|
80
|
+
: [])
|
|
81
|
+
.filter((cells) => cells.length > 0);
|
|
82
|
+
if (rows.length === 0) {
|
|
83
|
+
return '| |\n| --- |\n| |';
|
|
84
|
+
}
|
|
85
|
+
const header = rows[0];
|
|
86
|
+
const separator = header.map(() => '---');
|
|
87
|
+
const body = rows.slice(1);
|
|
88
|
+
return [
|
|
89
|
+
`| ${header.join(' | ')} |`,
|
|
90
|
+
`| ${separator.join(' | ')} |`,
|
|
91
|
+
...body.map((row) => `| ${row.join(' | ')} |`),
|
|
92
|
+
].join('\n');
|
|
93
|
+
}
|
|
94
|
+
function renderBlockMarkdown(block) {
|
|
95
|
+
const type = typeof block.type === 'string' ? block.type : '';
|
|
96
|
+
const valueEntry = getFirstValueEntry(block);
|
|
97
|
+
const text = normalizeWhitespace(extractText(block.value));
|
|
98
|
+
switch (type) {
|
|
99
|
+
case 'HeadingOne':
|
|
100
|
+
return text ? `# ${text}` : '#';
|
|
101
|
+
case 'HeadingTwo':
|
|
102
|
+
return text ? `## ${text}` : '##';
|
|
103
|
+
case 'HeadingThree':
|
|
104
|
+
return text ? `### ${text}` : '###';
|
|
105
|
+
case 'BulletedList':
|
|
106
|
+
return text ? `- ${text}` : '-';
|
|
107
|
+
case 'NumberedList':
|
|
108
|
+
return text ? `1. ${text}` : '1.';
|
|
109
|
+
case 'TodoList': {
|
|
110
|
+
const checked = getBooleanProp(valueEntry, 'checked') === true;
|
|
111
|
+
return `- [${checked ? 'x' : ' '}] ${text}`;
|
|
112
|
+
}
|
|
113
|
+
case 'Blockquote':
|
|
114
|
+
case 'Callout':
|
|
115
|
+
return text ? `> ${text}` : '>';
|
|
116
|
+
case 'Code': {
|
|
117
|
+
const language = getStringProp(valueEntry, 'language') ?? '';
|
|
118
|
+
const code = extractText(valueEntry?.children ?? []).trim();
|
|
119
|
+
return `\`\`\`${language}\n${code}\n\`\`\``;
|
|
120
|
+
}
|
|
121
|
+
case 'CodeGroup':
|
|
122
|
+
return valueEntry ? renderCodeGroupMarkdown(valueEntry) : '```text\n\n```';
|
|
123
|
+
case 'Divider':
|
|
124
|
+
return '---';
|
|
125
|
+
case 'Image': {
|
|
126
|
+
const src = getStringProp(valueEntry, 'src') ?? '';
|
|
127
|
+
const alt = getStringProp(valueEntry, 'alt') ?? '';
|
|
128
|
+
return ``;
|
|
129
|
+
}
|
|
130
|
+
case 'Table':
|
|
131
|
+
return valueEntry ? renderTableMarkdown(valueEntry) : '| |\n| --- |\n| |';
|
|
132
|
+
case 'Link': {
|
|
133
|
+
const href = getStringProp(valueEntry, 'href');
|
|
134
|
+
return href ? `[${text}](${href})` : text;
|
|
135
|
+
}
|
|
136
|
+
case 'Paragraph':
|
|
137
|
+
default:
|
|
138
|
+
return text;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function renderYooptaContent(value) {
|
|
142
|
+
assertValidYooptaContentValue(value);
|
|
143
|
+
if (!isRecord(value)) {
|
|
144
|
+
return { markdown: '', plainText: '' };
|
|
145
|
+
}
|
|
146
|
+
const blocks = Object.values(value).filter(isRecord).sort((left, right) => getBlockOrder(left) - getBlockOrder(right));
|
|
147
|
+
const markdownBlocks = blocks.map(renderBlockMarkdown).map((block) => block.trim()).filter(Boolean);
|
|
148
|
+
const plainTextBlocks = blocks
|
|
149
|
+
.map((block) => normalizeWhitespace(extractText(block.value)))
|
|
150
|
+
.filter(Boolean);
|
|
151
|
+
return {
|
|
152
|
+
markdown: markdownBlocks.join('\n\n'),
|
|
153
|
+
plainText: plainTextBlocks.join('\n\n'),
|
|
154
|
+
};
|
|
155
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anydocs/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"prepublishOnly": "pnpm build",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"test": "node --experimental-strip-types --test tests/**/*.test.ts"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.19.1",
|
|
28
|
+
"typescript": "^5.0.0"
|
|
29
|
+
}
|
|
30
|
+
}
|