@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.
Files changed (124) hide show
  1. package/dist/config/index.d.ts +2 -0
  2. package/dist/config/index.d.ts.map +1 -0
  3. package/dist/config/index.js +1 -0
  4. package/dist/config/project-config.d.ts +10 -0
  5. package/dist/config/project-config.d.ts.map +1 -0
  6. package/dist/config/project-config.js +52 -0
  7. package/dist/errors/domain-error.d.ts +12 -0
  8. package/dist/errors/domain-error.d.ts.map +1 -0
  9. package/dist/errors/domain-error.js +8 -0
  10. package/dist/errors/index.d.ts +3 -0
  11. package/dist/errors/index.d.ts.map +1 -0
  12. package/dist/errors/index.js +2 -0
  13. package/dist/errors/validation-error.d.ts +5 -0
  14. package/dist/errors/validation-error.d.ts.map +1 -0
  15. package/dist/errors/validation-error.js +7 -0
  16. package/dist/fs/api-source-repository.d.ts +16 -0
  17. package/dist/fs/api-source-repository.d.ts.map +1 -0
  18. package/dist/fs/api-source-repository.js +89 -0
  19. package/dist/fs/content-repository.d.ts +13 -0
  20. package/dist/fs/content-repository.d.ts.map +1 -0
  21. package/dist/fs/content-repository.js +171 -0
  22. package/dist/fs/docs-repository.d.ts +26 -0
  23. package/dist/fs/docs-repository.d.ts.map +1 -0
  24. package/dist/fs/docs-repository.js +270 -0
  25. package/dist/fs/index.d.ts +5 -0
  26. package/dist/fs/index.d.ts.map +1 -0
  27. package/dist/fs/index.js +4 -0
  28. package/dist/fs/project-paths.d.ts +4 -0
  29. package/dist/fs/project-paths.d.ts.map +1 -0
  30. package/dist/fs/project-paths.js +55 -0
  31. package/dist/index.d.ts +9 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +8 -0
  34. package/dist/publishing/build-artifacts.d.ts +4 -0
  35. package/dist/publishing/build-artifacts.d.ts.map +1 -0
  36. package/dist/publishing/build-artifacts.js +453 -0
  37. package/dist/publishing/build-openapi-artifacts.d.ts +3 -0
  38. package/dist/publishing/build-openapi-artifacts.d.ts.map +1 -0
  39. package/dist/publishing/build-openapi-artifacts.js +253 -0
  40. package/dist/publishing/index.d.ts +4 -0
  41. package/dist/publishing/index.d.ts.map +1 -0
  42. package/dist/publishing/index.js +3 -0
  43. package/dist/publishing/publication-filter.d.ts +22 -0
  44. package/dist/publishing/publication-filter.d.ts.map +1 -0
  45. package/dist/publishing/publication-filter.js +98 -0
  46. package/dist/schemas/api-source-schema.d.ts +3 -0
  47. package/dist/schemas/api-source-schema.d.ts.map +1 -0
  48. package/dist/schemas/api-source-schema.js +110 -0
  49. package/dist/schemas/docs-schema.d.ts +7 -0
  50. package/dist/schemas/docs-schema.d.ts.map +1 -0
  51. package/dist/schemas/docs-schema.js +212 -0
  52. package/dist/schemas/index.d.ts +4 -0
  53. package/dist/schemas/index.d.ts.map +1 -0
  54. package/dist/schemas/index.js +3 -0
  55. package/dist/schemas/project-schema.d.ts +3 -0
  56. package/dist/schemas/project-schema.d.ts.map +1 -0
  57. package/dist/schemas/project-schema.js +268 -0
  58. package/dist/services/authoring-service.d.ts +137 -0
  59. package/dist/services/authoring-service.d.ts.map +1 -0
  60. package/dist/services/authoring-service.js +583 -0
  61. package/dist/services/build-service.d.ts +35 -0
  62. package/dist/services/build-service.d.ts.map +1 -0
  63. package/dist/services/build-service.js +84 -0
  64. package/dist/services/index.d.ts +11 -0
  65. package/dist/services/index.d.ts.map +1 -0
  66. package/dist/services/index.js +10 -0
  67. package/dist/services/init-service.d.ts +15 -0
  68. package/dist/services/init-service.d.ts.map +1 -0
  69. package/dist/services/init-service.js +127 -0
  70. package/dist/services/legacy-conversion-service.d.ts +8 -0
  71. package/dist/services/legacy-conversion-service.d.ts.map +1 -0
  72. package/dist/services/legacy-conversion-service.js +601 -0
  73. package/dist/services/legacy-import-service.d.ts +10 -0
  74. package/dist/services/legacy-import-service.d.ts.map +1 -0
  75. package/dist/services/legacy-import-service.js +239 -0
  76. package/dist/services/page-template-service.d.ts +81 -0
  77. package/dist/services/page-template-service.d.ts.map +1 -0
  78. package/dist/services/page-template-service.js +342 -0
  79. package/dist/services/preview-service.d.ts +29 -0
  80. package/dist/services/preview-service.d.ts.map +1 -0
  81. package/dist/services/preview-service.js +45 -0
  82. package/dist/services/watch-service.d.ts +24 -0
  83. package/dist/services/watch-service.d.ts.map +1 -0
  84. package/dist/services/watch-service.js +216 -0
  85. package/dist/services/web-runtime-bridge.d.ts +33 -0
  86. package/dist/services/web-runtime-bridge.d.ts.map +1 -0
  87. package/dist/services/web-runtime-bridge.js +330 -0
  88. package/dist/services/workflow-compatibility-service.d.ts +3 -0
  89. package/dist/services/workflow-compatibility-service.d.ts.map +1 -0
  90. package/dist/services/workflow-compatibility-service.js +53 -0
  91. package/dist/services/workflow-standard-service.d.ts +9 -0
  92. package/dist/services/workflow-standard-service.d.ts.map +1 -0
  93. package/dist/services/workflow-standard-service.js +372 -0
  94. package/dist/types/api-source.d.ts +34 -0
  95. package/dist/types/api-source.d.ts.map +1 -0
  96. package/dist/types/api-source.js +8 -0
  97. package/dist/types/docs.d.ts +65 -0
  98. package/dist/types/docs.d.ts.map +1 -0
  99. package/dist/types/docs.js +8 -0
  100. package/dist/types/index.d.ts +6 -0
  101. package/dist/types/index.d.ts.map +1 -0
  102. package/dist/types/index.js +5 -0
  103. package/dist/types/legacy-import.d.ts +72 -0
  104. package/dist/types/legacy-import.d.ts.map +1 -0
  105. package/dist/types/legacy-import.js +1 -0
  106. package/dist/types/project.d.ts +85 -0
  107. package/dist/types/project.d.ts.map +1 -0
  108. package/dist/types/project.js +5 -0
  109. package/dist/types/workflow-standard.d.ts +51 -0
  110. package/dist/types/workflow-standard.d.ts.map +1 -0
  111. package/dist/types/workflow-standard.js +1 -0
  112. package/dist/utils/index.d.ts +4 -0
  113. package/dist/utils/index.d.ts.map +1 -0
  114. package/dist/utils/index.js +3 -0
  115. package/dist/utils/slug.d.ts +3 -0
  116. package/dist/utils/slug.d.ts.map +1 -0
  117. package/dist/utils/slug.js +21 -0
  118. package/dist/utils/yoopta-content.d.ts +13 -0
  119. package/dist/utils/yoopta-content.d.ts.map +1 -0
  120. package/dist/utils/yoopta-content.js +73 -0
  121. package/dist/utils/yoopta-render.d.ts +7 -0
  122. package/dist/utils/yoopta-render.d.ts.map +1 -0
  123. package/dist/utils/yoopta-render.js +155 -0
  124. package/package.json +30 -0
@@ -0,0 +1,372 @@
1
+ import path from 'node:path';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { ValidationError } from "../errors/validation-error.js";
4
+ import { PAGE_STATUSES } from "../types/docs.js";
5
+ function relativeToRepo(contract, targetPath) {
6
+ return path.relative(contract.paths.repoRoot, targetPath) || '.';
7
+ }
8
+ function createSourceFiles(contract) {
9
+ const files = [
10
+ {
11
+ id: 'projectConfig',
12
+ path: relativeToRepo(contract, contract.paths.configFile),
13
+ format: 'json',
14
+ required: true,
15
+ writable: true,
16
+ generated: false,
17
+ description: 'Canonical project configuration for authoring, build, and preview.',
18
+ },
19
+ {
20
+ id: 'workflowStandard',
21
+ path: relativeToRepo(contract, contract.paths.workflowFile),
22
+ format: 'json',
23
+ required: true,
24
+ writable: true,
25
+ generated: false,
26
+ description: 'Reusable workflow contract for external automation and future AI-native flows.',
27
+ },
28
+ ];
29
+ for (const language of contract.config.languages) {
30
+ const roots = contract.paths.languageRoots[language];
31
+ files.push({
32
+ id: 'navigation',
33
+ path: relativeToRepo(contract, roots.navigationFile),
34
+ format: 'json',
35
+ required: true,
36
+ writable: true,
37
+ generated: false,
38
+ description: `Navigation tree for ${language}.`,
39
+ });
40
+ files.push({
41
+ id: 'page',
42
+ path: relativeToRepo(contract, path.join(roots.pagesDir, '{pageId}.json')),
43
+ format: 'json',
44
+ required: true,
45
+ writable: true,
46
+ generated: false,
47
+ description: `Page document pattern for ${language}.`,
48
+ });
49
+ }
50
+ files.push({
51
+ id: 'apiSource',
52
+ path: relativeToRepo(contract, path.join(contract.paths.apiSourcesRoot, '{sourceId}.json')),
53
+ format: 'json',
54
+ required: false,
55
+ writable: true,
56
+ generated: false,
57
+ description: 'API source document pattern for OpenAPI-backed reference surfaces.',
58
+ });
59
+ return files;
60
+ }
61
+ function createGeneratedArtifacts(contract) {
62
+ const artifacts = [
63
+ {
64
+ id: 'llms',
65
+ path: relativeToRepo(contract, contract.paths.llmsFile),
66
+ format: 'text',
67
+ required: false,
68
+ writable: false,
69
+ generated: true,
70
+ description: 'AI-friendly published artifact generated from published content only.',
71
+ },
72
+ {
73
+ id: 'llmsFull',
74
+ path: relativeToRepo(contract, path.join(contract.paths.artifactRoot, 'llms-full.txt')),
75
+ format: 'text',
76
+ required: false,
77
+ writable: false,
78
+ generated: true,
79
+ description: 'Full-site AI-readable fallback export generated from published content only.',
80
+ },
81
+ {
82
+ id: 'machineReadableRoot',
83
+ path: relativeToRepo(contract, contract.paths.machineReadableRoot),
84
+ format: 'directory',
85
+ required: false,
86
+ writable: false,
87
+ generated: true,
88
+ description: 'Machine-readable published artifacts generated from canonical publication rules.',
89
+ },
90
+ {
91
+ id: 'machineReadableIndex',
92
+ path: relativeToRepo(contract, path.join(contract.paths.machineReadableRoot, 'index.json')),
93
+ format: 'json',
94
+ required: false,
95
+ writable: false,
96
+ generated: true,
97
+ description: 'Stable machine-readable artifact index for external AI and automation consumers.',
98
+ },
99
+ {
100
+ id: 'openApiRoot',
101
+ path: relativeToRepo(contract, path.join(contract.paths.machineReadableRoot, 'openapi')),
102
+ format: 'directory',
103
+ required: false,
104
+ writable: false,
105
+ generated: true,
106
+ description: 'Machine-readable OpenAPI artifacts generated from published api sources.',
107
+ },
108
+ ];
109
+ for (const language of contract.config.languages) {
110
+ artifacts.push({
111
+ id: 'openApiIndex',
112
+ path: relativeToRepo(contract, path.join(contract.paths.machineReadableRoot, 'openapi', `index.${language}.json`)),
113
+ format: 'json',
114
+ required: false,
115
+ writable: false,
116
+ generated: true,
117
+ description: `Machine-readable OpenAPI source index for ${language}.`,
118
+ });
119
+ artifacts.push({
120
+ id: 'searchIndex',
121
+ path: relativeToRepo(contract, contract.paths.languageRoots[language].searchIndexFile),
122
+ format: 'json',
123
+ required: false,
124
+ writable: false,
125
+ generated: true,
126
+ description: `Static search index for ${language}.`,
127
+ });
128
+ artifacts.push({
129
+ id: 'chunkIndex',
130
+ path: relativeToRepo(contract, path.join(contract.paths.machineReadableRoot, `chunks.${language}.json`)),
131
+ format: 'json',
132
+ required: false,
133
+ writable: false,
134
+ generated: true,
135
+ description: `Machine-readable chunk artifact for ${language}.`,
136
+ });
137
+ }
138
+ return artifacts;
139
+ }
140
+ function createWorkflowValidationError(rule, remediation, metadata) {
141
+ return new ValidationError(`Workflow standard validation failed for rule "${rule}".`, {
142
+ entity: 'workflow-standard',
143
+ rule,
144
+ remediation,
145
+ metadata,
146
+ });
147
+ }
148
+ function isRecord(value) {
149
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
150
+ }
151
+ function assertStringArray(value, rule, remediation) {
152
+ if (!Array.isArray(value) || value.some((entry) => typeof entry !== 'string' || entry.trim().length === 0)) {
153
+ throw createWorkflowValidationError(rule, remediation, { received: value });
154
+ }
155
+ }
156
+ export function validateWorkflowStandardDefinition(input) {
157
+ if (!isRecord(input)) {
158
+ throw createWorkflowValidationError('workflow-standard-object', 'Ensure anydocs.workflow.json contains a JSON object matching the canonical workflow standard definition.', { received: input });
159
+ }
160
+ if (input.version !== 1) {
161
+ throw createWorkflowValidationError('workflow-standard-version', 'Regenerate anydocs.workflow.json with the current anydocs init or workflow export logic.', { received: input.version });
162
+ }
163
+ if (input.standardId !== 'anydocs-phase-1') {
164
+ throw createWorkflowValidationError('workflow-standard-id', 'Use the canonical anydocs-phase-1 workflow standard id.', { received: input.standardId });
165
+ }
166
+ if (input.projectContractVersion !== 1) {
167
+ throw createWorkflowValidationError('workflow-standard-project-contract-version', 'Use a workflow standard generated from the current project contract version.', { received: input.projectContractVersion });
168
+ }
169
+ if (input.localFirst !== true || input.uiIndependent !== true) {
170
+ throw createWorkflowValidationError('workflow-standard-core-flags', 'Preserve localFirst and uiIndependent as true for the phase 1 workflow standard.', { localFirst: input.localFirst, uiIndependent: input.uiIndependent });
171
+ }
172
+ assertStringArray(input.supportedLanguages, 'workflow-standard-supported-languages', 'List supported languages as non-empty string identifiers in anydocs.workflow.json.');
173
+ assertStringArray(input.enabledLanguages, 'workflow-standard-enabled-languages', 'List enabled languages as non-empty string identifiers in anydocs.workflow.json.');
174
+ assertStringArray(input.publicationStatuses, 'workflow-standard-publication-statuses', 'List publication statuses as non-empty string identifiers in anydocs.workflow.json.');
175
+ assertStringArray(input.publishedStatuses, 'workflow-standard-published-statuses', 'List published statuses as non-empty string identifiers in anydocs.workflow.json.');
176
+ if (!Array.isArray(input.sourceFiles) || input.sourceFiles.some((file) => !isRecord(file))) {
177
+ throw createWorkflowValidationError('workflow-standard-source-files', 'Define sourceFiles as an array of workflow standard file descriptors.', { received: input.sourceFiles });
178
+ }
179
+ if (!Array.isArray(input.generatedArtifacts) || input.generatedArtifacts.some((file) => !isRecord(file))) {
180
+ throw createWorkflowValidationError('workflow-standard-generated-artifacts', 'Define generatedArtifacts as an array of workflow standard file descriptors.', { received: input.generatedArtifacts });
181
+ }
182
+ if (!isRecord(input.contentModel)) {
183
+ throw createWorkflowValidationError('workflow-standard-content-model', 'Define contentModel as an object describing config, page, and navigation fields.', { received: input.contentModel });
184
+ }
185
+ assertStringArray(input.contentModel.projectConfigFields, 'workflow-standard-project-config-fields', 'List projectConfigFields as strings in the workflow standard content model.');
186
+ assertStringArray(input.contentModel.pageRequiredFields, 'workflow-standard-page-required-fields', 'List pageRequiredFields as strings in the workflow standard content model.');
187
+ assertStringArray(input.contentModel.pageOptionalFields, 'workflow-standard-page-optional-fields', 'List pageOptionalFields as strings in the workflow standard content model.');
188
+ assertStringArray(input.contentModel.navigationRequiredFields, 'workflow-standard-navigation-required-fields', 'List navigationRequiredFields as strings in the workflow standard content model.');
189
+ if (!isRecord(input.orchestration)) {
190
+ throw createWorkflowValidationError('workflow-standard-orchestration', 'Define orchestration as an object containing workflow steps and compatibility flags.', { received: input.orchestration });
191
+ }
192
+ assertStringArray(input.orchestration.workflowSteps, 'workflow-standard-workflow-steps', 'List orchestration.workflowSteps as strings in the canonical order.');
193
+ if (input.orchestration.publicationRule !== 'published-only') {
194
+ throw createWorkflowValidationError('workflow-standard-publication-rule', 'Use the canonical published-only publication rule in the workflow standard.', { received: input.orchestration.publicationRule });
195
+ }
196
+ if (input.orchestration.futureCompatibleWithoutReinitialization !== true ||
197
+ input.orchestration.externalAutomationReady !== true) {
198
+ throw createWorkflowValidationError('workflow-standard-compatibility-flags', 'Preserve futureCompatibleWithoutReinitialization and externalAutomationReady as true in the workflow standard.', {
199
+ futureCompatibleWithoutReinitialization: input.orchestration.futureCompatibleWithoutReinitialization,
200
+ externalAutomationReady: input.orchestration.externalAutomationReady,
201
+ });
202
+ }
203
+ return input;
204
+ }
205
+ function toComparableWorkflowFile(file) {
206
+ return {
207
+ id: file.id,
208
+ path: file.path,
209
+ format: file.format,
210
+ required: file.required,
211
+ writable: file.writable,
212
+ generated: file.generated,
213
+ description: file.description,
214
+ };
215
+ }
216
+ function toComparableWorkflowDefinition(definition) {
217
+ return {
218
+ version: definition.version,
219
+ standardId: definition.standardId,
220
+ projectContractVersion: definition.projectContractVersion,
221
+ localFirst: definition.localFirst,
222
+ uiIndependent: definition.uiIndependent,
223
+ supportedLanguages: definition.supportedLanguages,
224
+ enabledLanguages: definition.enabledLanguages,
225
+ publicationStatuses: definition.publicationStatuses,
226
+ publishedStatuses: definition.publishedStatuses,
227
+ sourceFiles: definition.sourceFiles.map(toComparableWorkflowFile),
228
+ // Note: generatedArtifacts paths are excluded from comparison because they depend on
229
+ // the build output directory, which can be customized via CLI --output or config.
230
+ // We only validate source files and configuration.
231
+ contentModel: definition.contentModel,
232
+ orchestration: definition.orchestration,
233
+ };
234
+ }
235
+ function createWorkflowFileKey(file) {
236
+ return `${file.id}:${file.path}`;
237
+ }
238
+ function hasCompatibleSourceFiles(persisted, expected) {
239
+ const persistedByKey = new Map(persisted.map((file) => [createWorkflowFileKey(file), file]));
240
+ for (const expectedFile of expected) {
241
+ const persistedFile = persistedByKey.get(createWorkflowFileKey(expectedFile));
242
+ if (!persistedFile) {
243
+ if (expectedFile.required) {
244
+ return false;
245
+ }
246
+ continue;
247
+ }
248
+ if (JSON.stringify(persistedFile) !== JSON.stringify(expectedFile)) {
249
+ return false;
250
+ }
251
+ }
252
+ return true;
253
+ }
254
+ export async function readWorkflowStandardDefinition(workflowFile) {
255
+ const raw = await readFile(workflowFile, 'utf8').catch(() => {
256
+ throw createWorkflowValidationError('workflow-standard-file-readable', 'Ensure anydocs.workflow.json exists and is readable before validating workflow compatibility.', { workflowFile });
257
+ });
258
+ try {
259
+ return validateWorkflowStandardDefinition(JSON.parse(raw));
260
+ }
261
+ catch (error) {
262
+ if (error instanceof ValidationError) {
263
+ throw error;
264
+ }
265
+ throw createWorkflowValidationError('workflow-standard-json-valid', 'Fix anydocs.workflow.json so it contains valid JSON before validating workflow compatibility.', {
266
+ workflowFile,
267
+ cause: error instanceof Error ? error.message : String(error),
268
+ });
269
+ }
270
+ }
271
+ export function assertWorkflowStandardMatchesContract(definition, contract) {
272
+ const expected = createWorkflowStandardDefinition(contract);
273
+ const comparablePersisted = toComparableWorkflowDefinition(definition);
274
+ const comparableExpected = toComparableWorkflowDefinition(expected);
275
+ const comparablePersistedCore = {
276
+ ...comparablePersisted,
277
+ sourceFiles: undefined,
278
+ };
279
+ const comparableExpectedCore = {
280
+ ...comparableExpected,
281
+ sourceFiles: undefined,
282
+ };
283
+ if (JSON.stringify(comparablePersistedCore) !== JSON.stringify(comparableExpectedCore) ||
284
+ !hasCompatibleSourceFiles(comparablePersisted.sourceFiles, comparableExpected.sourceFiles)) {
285
+ throw createWorkflowValidationError('workflow-standard-matches-project-contract', 'Regenerate anydocs.workflow.json so its languages, file paths, and publication rules match the current canonical project contract.', {
286
+ expected: comparableExpected,
287
+ received: comparablePersisted,
288
+ });
289
+ }
290
+ }
291
+ export function createWorkflowStandardDefinition(contract) {
292
+ return {
293
+ version: 1,
294
+ standardId: 'anydocs-phase-1',
295
+ projectContractVersion: contract.config.version,
296
+ localFirst: true,
297
+ uiIndependent: true,
298
+ supportedLanguages: ['zh', 'en'],
299
+ enabledLanguages: contract.config.languages,
300
+ publicationStatuses: [...PAGE_STATUSES],
301
+ publishedStatuses: ['published'],
302
+ sourceFiles: createSourceFiles(contract),
303
+ generatedArtifacts: createGeneratedArtifacts(contract),
304
+ contentModel: {
305
+ projectConfigFields: ['version', 'projectId', 'name', 'defaultLanguage', 'languages', 'site', 'build'],
306
+ pageRequiredFields: ['id', 'lang', 'slug', 'title', 'status', 'content'],
307
+ pageOptionalFields: ['description', 'tags', 'updatedAt', 'render'],
308
+ navigationRequiredFields: ['version', 'items'],
309
+ },
310
+ orchestration: {
311
+ workflowSteps: [
312
+ 'loadConfig',
313
+ 'loadContent',
314
+ 'validate',
315
+ 'persistSources',
316
+ 'filterPublished',
317
+ 'generateArtifacts',
318
+ 'reportResult',
319
+ ],
320
+ publicationRule: 'published-only',
321
+ futureCompatibleWithoutReinitialization: true,
322
+ externalAutomationReady: true,
323
+ },
324
+ };
325
+ }
326
+ export function renderWorkflowStandardGuide(definition) {
327
+ const sourceFiles = definition.sourceFiles
328
+ .map((file) => `- ${file.path} (${file.description})`)
329
+ .join('\n');
330
+ const generatedArtifacts = definition.generatedArtifacts
331
+ .map((file) => `- ${file.path} (${file.description})`)
332
+ .join('\n');
333
+ const workflowSteps = definition.orchestration.workflowSteps.map((step) => `- ${step}`).join('\n');
334
+ return [
335
+ '# Anydocs Workflow Standard',
336
+ '',
337
+ `Standard ID: ${definition.standardId}`,
338
+ `Project Contract Version: ${definition.projectContractVersion}`,
339
+ `Local First: ${definition.localFirst ? 'yes' : 'no'}`,
340
+ `UI Independent: ${definition.uiIndependent ? 'yes' : 'no'}`,
341
+ `Enabled Languages: ${definition.enabledLanguages.join(', ')}`,
342
+ `Publication Statuses: ${definition.publicationStatuses.join(', ')}`,
343
+ `Published Output Rule: ${definition.orchestration.publicationRule}`,
344
+ '',
345
+ '## Source Files',
346
+ sourceFiles,
347
+ '',
348
+ '## Generated Artifacts',
349
+ generatedArtifacts,
350
+ '',
351
+ '## Content Model',
352
+ `- Project config fields: ${definition.contentModel.projectConfigFields.join(', ')}`,
353
+ `- Page required fields: ${definition.contentModel.pageRequiredFields.join(', ')}`,
354
+ `- Page optional fields: ${definition.contentModel.pageOptionalFields.join(', ')}`,
355
+ `- Navigation required fields: ${definition.contentModel.navigationRequiredFields.join(', ')}`,
356
+ '',
357
+ '## Workflow Steps',
358
+ workflowSteps,
359
+ '',
360
+ '## Compatibility Rules',
361
+ '- Future automation may create or modify source files directly as long as it preserves the same config, page, and navigation schemas.',
362
+ '- No project reinitialization is required when later workflows reuse this standard.',
363
+ '- Generated artifacts must not be edited by hand.',
364
+ ].join('\n');
365
+ }
366
+ export function exportWorkflowStandard(contract) {
367
+ const definition = createWorkflowStandardDefinition(contract);
368
+ return {
369
+ definition,
370
+ markdownGuide: renderWorkflowStandardGuide(definition),
371
+ };
372
+ }
@@ -0,0 +1,34 @@
1
+ import type { DocsLang } from './docs.ts';
2
+ export declare const API_SOURCE_TYPES: readonly ["openapi"];
3
+ export type ApiSourceType = (typeof API_SOURCE_TYPES)[number];
4
+ export declare const API_SOURCE_STATUSES: readonly ["draft", "published"];
5
+ export type ApiSourceStatus = (typeof API_SOURCE_STATUSES)[number];
6
+ export type ApiSourceInput = {
7
+ kind: 'url';
8
+ url: string;
9
+ } | {
10
+ kind: 'file';
11
+ path: string;
12
+ };
13
+ export type ApiSourceDisplay = {
14
+ title: string;
15
+ groupId?: string;
16
+ };
17
+ export type ApiSourceRuntime = {
18
+ routeBase?: string;
19
+ tryIt?: {
20
+ enabled: boolean;
21
+ };
22
+ };
23
+ export type ApiSourceDoc = {
24
+ id: string;
25
+ type: ApiSourceType;
26
+ lang: DocsLang;
27
+ status: ApiSourceStatus;
28
+ source: ApiSourceInput;
29
+ display: ApiSourceDisplay;
30
+ runtime?: ApiSourceRuntime;
31
+ };
32
+ export declare function isApiSourceType(value: unknown): value is ApiSourceType;
33
+ export declare function isApiSourceStatus(value: unknown): value is ApiSourceStatus;
34
+ //# sourceMappingURL=api-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-source.d.ts","sourceRoot":"","sources":["../../src/types/api-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,eAAO,MAAM,gBAAgB,sBAAuB,CAAC;AACrD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,eAAO,MAAM,mBAAmB,iCAAkC,CAAC;AACnE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,MAAM,MAAM,cAAc,GACtB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E"}
@@ -0,0 +1,8 @@
1
+ export const API_SOURCE_TYPES = ['openapi'];
2
+ export const API_SOURCE_STATUSES = ['draft', 'published'];
3
+ export function isApiSourceType(value) {
4
+ return typeof value === 'string' && API_SOURCE_TYPES.includes(value);
5
+ }
6
+ export function isApiSourceStatus(value) {
7
+ return typeof value === 'string' && API_SOURCE_STATUSES.includes(value);
8
+ }
@@ -0,0 +1,65 @@
1
+ export declare const DOCS_LANGUAGES: readonly ["zh", "en"];
2
+ export type DocsLang = (typeof DOCS_LANGUAGES)[number];
3
+ export declare const PAGE_STATUSES: readonly ["draft", "in_review", "published"];
4
+ export type PageStatus = (typeof PAGE_STATUSES)[number];
5
+ export type PageRender = {
6
+ markdown?: string;
7
+ plainText?: string;
8
+ };
9
+ export type PageReviewWarning = {
10
+ code: string;
11
+ message: string;
12
+ remediation?: string;
13
+ metadata?: Record<string, unknown>;
14
+ };
15
+ export type PageReviewSourceType = 'legacy-import' | 'ai-generated';
16
+ export type PageReview = {
17
+ required: boolean;
18
+ sourceType: PageReviewSourceType;
19
+ sourceId: string;
20
+ itemId?: string;
21
+ sourcePath?: string;
22
+ approvedAt?: string;
23
+ metadata?: Record<string, unknown>;
24
+ warnings?: PageReviewWarning[];
25
+ };
26
+ export type PageDoc<TContent = unknown> = {
27
+ id: string;
28
+ lang: DocsLang;
29
+ slug: string;
30
+ title: string;
31
+ description?: string;
32
+ tags?: string[];
33
+ status: PageStatus;
34
+ updatedAt?: string;
35
+ content: TContent;
36
+ render?: PageRender;
37
+ review?: PageReview;
38
+ };
39
+ export type NavItem = {
40
+ type: 'section';
41
+ id?: string;
42
+ title: string;
43
+ children: NavItem[];
44
+ } | {
45
+ type: 'folder';
46
+ id?: string;
47
+ title: string;
48
+ children: NavItem[];
49
+ } | {
50
+ type: 'page';
51
+ pageId: string;
52
+ titleOverride?: string;
53
+ hidden?: boolean;
54
+ } | {
55
+ type: 'link';
56
+ title: string;
57
+ href: string;
58
+ };
59
+ export type NavigationDoc = {
60
+ version: number;
61
+ items: NavItem[];
62
+ };
63
+ export declare function isDocsLang(value: unknown): value is DocsLang;
64
+ export declare function isPageStatus(value: unknown): value is PageStatus;
65
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/types/docs.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,uBAAwB,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,aAAa,8CAA+C,CAAC;AAE1E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG,cAAc,CAAC;AAEpE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,oBAAoB,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAA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EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE"}
@@ -0,0 +1,8 @@
1
+ export const DOCS_LANGUAGES = ['zh', 'en'];
2
+ export const PAGE_STATUSES = ['draft', 'in_review', 'published'];
3
+ export function isDocsLang(value) {
4
+ return typeof value === 'string' && DOCS_LANGUAGES.includes(value);
5
+ }
6
+ export function isPageStatus(value) {
7
+ return typeof value === 'string' && PAGE_STATUSES.includes(value);
8
+ }
@@ -0,0 +1,6 @@
1
+ export * from './api-source.ts';
2
+ export * from './docs.ts';
3
+ export * from './legacy-import.ts';
4
+ export * from './project.ts';
5
+ export * from './workflow-standard.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./api-source.js";
2
+ export * from "./docs.js";
3
+ export * from "./legacy-import.js";
4
+ export * from "./project.js";
5
+ export * from "./workflow-standard.js";
@@ -0,0 +1,72 @@
1
+ import type { DocsLanguage } from './project.ts';
2
+ export type LegacyImportFormat = 'markdown' | 'mdx';
3
+ export type LegacyImportStatus = 'staged' | 'converted';
4
+ export type LegacyImportFrontmatterValue = string | string[];
5
+ export type LegacyImportWarning = {
6
+ itemId?: string;
7
+ code: string;
8
+ message: string;
9
+ remediation?: string;
10
+ metadata?: Record<string, unknown>;
11
+ };
12
+ export type LegacyImportItem = {
13
+ id: string;
14
+ sourcePath: string;
15
+ lang: DocsLanguage;
16
+ slug: string;
17
+ title: string;
18
+ description?: string;
19
+ tags?: string[];
20
+ format: LegacyImportFormat;
21
+ importedAt: string;
22
+ rawContent: string;
23
+ body: string;
24
+ frontmatter: Record<string, LegacyImportFrontmatterValue>;
25
+ status: LegacyImportStatus;
26
+ convertedAt?: string;
27
+ };
28
+ export type LegacyImportManifestItem = Pick<LegacyImportItem, 'id' | 'sourcePath' | 'lang' | 'slug' | 'title' | 'format' | 'status'>;
29
+ export type LegacyImportManifest = {
30
+ version: 1;
31
+ importId: string;
32
+ projectId: string;
33
+ sourceRoot: string;
34
+ importedAt: string;
35
+ itemCount: number;
36
+ status: LegacyImportStatus;
37
+ items: LegacyImportManifestItem[];
38
+ };
39
+ export type LegacyImportResult = {
40
+ importId: string;
41
+ importRoot: string;
42
+ manifestFile: string;
43
+ itemCount: number;
44
+ items: LegacyImportManifestItem[];
45
+ };
46
+ export type LegacyImportConversionItem = {
47
+ itemId: string;
48
+ pageId: string;
49
+ lang: DocsLanguage;
50
+ slug: string;
51
+ status: 'draft';
52
+ warnings: LegacyImportWarning[];
53
+ };
54
+ export type LegacyImportConversionReport = {
55
+ version: 1;
56
+ importId: string;
57
+ projectId: string;
58
+ convertedAt: string;
59
+ status: 'converted';
60
+ convertedCount: number;
61
+ items: LegacyImportConversionItem[];
62
+ warnings: LegacyImportWarning[];
63
+ };
64
+ export type LegacyImportConversionResult = {
65
+ importId: string;
66
+ importRoot: string;
67
+ reportFile: string;
68
+ convertedCount: number;
69
+ items: LegacyImportConversionItem[];
70
+ warnings: LegacyImportWarning[];
71
+ };
72
+ //# sourceMappingURL=legacy-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-import.d.ts","sourceRoot":"","sources":["../../src/types/legacy-import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,KAAK,CAAC;AACpD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,WAAW,CAAC;AAExD,MAAM,MAAM,4BAA4B,GAAG,MAAM,G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