@json-to-office/shared-docx 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 +18 -0
- package/README.md +9 -0
- package/dist/chunk-5533WPL6.js +1895 -0
- package/dist/chunk-5533WPL6.js.map +1 -0
- package/dist/chunk-AA4HIXRG.js +34 -0
- package/dist/chunk-AA4HIXRG.js.map +1 -0
- package/dist/chunk-BEPLK76M.js +454 -0
- package/dist/chunk-BEPLK76M.js.map +1 -0
- package/dist/chunk-BOUURUYX.js +364 -0
- package/dist/chunk-BOUURUYX.js.map +1 -0
- package/dist/chunk-EKWM2CWA.js +97 -0
- package/dist/chunk-EKWM2CWA.js.map +1 -0
- package/dist/chunk-ET6YMNMF.js +35 -0
- package/dist/chunk-ET6YMNMF.js.map +1 -0
- package/dist/chunk-F5LVWDTY.js +57 -0
- package/dist/chunk-F5LVWDTY.js.map +1 -0
- package/dist/chunk-HHMK2RWF.js +274 -0
- package/dist/chunk-HHMK2RWF.js.map +1 -0
- package/dist/chunk-LOE6BZQG.js +750 -0
- package/dist/chunk-LOE6BZQG.js.map +1 -0
- package/dist/chunk-LWR4TFZ5.js +121 -0
- package/dist/chunk-LWR4TFZ5.js.map +1 -0
- package/dist/chunk-VP3X6DBP.js +44 -0
- package/dist/chunk-VP3X6DBP.js.map +1 -0
- package/dist/document-validator-CiaGiy1v.d.ts +119 -0
- package/dist/index.d.ts +938 -0
- package/dist/index.js +1129 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/api.d.ts +46 -0
- package/dist/schemas/api.js +16 -0
- package/dist/schemas/api.js.map +1 -0
- package/dist/schemas/component-registry.d.ts +90 -0
- package/dist/schemas/component-registry.js +24 -0
- package/dist/schemas/component-registry.js.map +1 -0
- package/dist/schemas/components.d.ts +755 -0
- package/dist/schemas/components.js +94 -0
- package/dist/schemas/components.js.map +1 -0
- package/dist/schemas/custom-components.d.ts +59 -0
- package/dist/schemas/custom-components.js +11 -0
- package/dist/schemas/custom-components.js.map +1 -0
- package/dist/schemas/document.d.ts +43 -0
- package/dist/schemas/document.js +19 -0
- package/dist/schemas/document.js.map +1 -0
- package/dist/schemas/export.d.ts +67 -0
- package/dist/schemas/export.js +19 -0
- package/dist/schemas/export.js.map +1 -0
- package/dist/schemas/font.d.ts +57 -0
- package/dist/schemas/font.js +11 -0
- package/dist/schemas/font.js.map +1 -0
- package/dist/schemas/generator.d.ts +80 -0
- package/dist/schemas/generator.js +9 -0
- package/dist/schemas/generator.js.map +1 -0
- package/dist/schemas/theme.d.ts +3354 -0
- package/dist/schemas/theme.js +42 -0
- package/dist/schemas/theme.js.map +1 -0
- package/dist/validation/unified/index.d.ts +720 -0
- package/dist/validation/unified/index.js +154 -0
- package/dist/validation/unified/index.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// src/schemas/export.ts
|
|
2
|
+
function fixSchemaReferences(schema, rootDefinitionName = "ComponentDefinition") {
|
|
3
|
+
function traverse(obj, path = "") {
|
|
4
|
+
if (typeof obj !== "object" || obj === null) return;
|
|
5
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
6
|
+
const currentPath = path ? `${path}.${key}` : key;
|
|
7
|
+
if (value && typeof value === "object") {
|
|
8
|
+
const schemaValue = value;
|
|
9
|
+
if (schemaValue.type === "array" && schemaValue.items && Object.keys(schemaValue.items).length === 0) {
|
|
10
|
+
schemaValue.items = {
|
|
11
|
+
$ref: `#/definitions/${rootDefinitionName}`
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (schemaValue.type === "array" && schemaValue.items && typeof schemaValue.items === "object" && "$ref" in schemaValue.items && schemaValue.items.$ref === "T0") {
|
|
15
|
+
schemaValue.items = {
|
|
16
|
+
$ref: `#/definitions/${rootDefinitionName}`
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (schemaValue.$ref === "T0" || schemaValue.$ref === rootDefinitionName) {
|
|
20
|
+
schemaValue.$ref = `#/definitions/${rootDefinitionName}`;
|
|
21
|
+
}
|
|
22
|
+
if (key === "$id" && typeof value === "string" && (value === "T0" || value === rootDefinitionName) && currentPath !== `definitions.${rootDefinitionName}.$id`) {
|
|
23
|
+
delete obj[key];
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
traverse(value, currentPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
traverse(schema);
|
|
31
|
+
}
|
|
32
|
+
function convertToJsonSchema(schema, options = {}) {
|
|
33
|
+
const {
|
|
34
|
+
$schema = "https://json-schema.org/draft-07/schema#",
|
|
35
|
+
$id,
|
|
36
|
+
title,
|
|
37
|
+
description,
|
|
38
|
+
definitions = {}
|
|
39
|
+
} = options;
|
|
40
|
+
const schemaJson = JSON.parse(JSON.stringify(schema));
|
|
41
|
+
const extractedDefinitions = { ...definitions };
|
|
42
|
+
function extractRecursiveSchemas(obj, path = "") {
|
|
43
|
+
if (typeof obj !== "object" || obj === null) return;
|
|
44
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
45
|
+
if (value && typeof value === "object") {
|
|
46
|
+
const schemaValue = value;
|
|
47
|
+
if (schemaValue.$id && typeof schemaValue.$id === "string") {
|
|
48
|
+
const definitionName = schemaValue.$id;
|
|
49
|
+
if (path !== `definitions.${definitionName}`) {
|
|
50
|
+
const { $id: _, ...schemaWithoutId } = schemaValue;
|
|
51
|
+
extractedDefinitions[definitionName] = schemaWithoutId;
|
|
52
|
+
obj[key] = { $ref: `#/definitions/${definitionName}` };
|
|
53
|
+
extractRecursiveSchemas(
|
|
54
|
+
schemaWithoutId,
|
|
55
|
+
`definitions.${definitionName}`
|
|
56
|
+
);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
extractRecursiveSchemas(
|
|
61
|
+
value,
|
|
62
|
+
path ? `${path}.${key}` : key
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
extractRecursiveSchemas(schemaJson);
|
|
68
|
+
const jsonSchema = {
|
|
69
|
+
$schema
|
|
70
|
+
};
|
|
71
|
+
if ($id) jsonSchema.$id = $id;
|
|
72
|
+
Object.assign(jsonSchema, schemaJson);
|
|
73
|
+
if (title !== void 0) jsonSchema.title = title;
|
|
74
|
+
if (description !== void 0) jsonSchema.description = description;
|
|
75
|
+
if (Object.keys(extractedDefinitions).length > 0) {
|
|
76
|
+
jsonSchema.definitions = extractedDefinitions;
|
|
77
|
+
}
|
|
78
|
+
fixSchemaReferences(jsonSchema);
|
|
79
|
+
return jsonSchema;
|
|
80
|
+
}
|
|
81
|
+
function createComponentSchema(name, config, componentDefinitionSchema) {
|
|
82
|
+
const componentStructure = {
|
|
83
|
+
$schema: "https://json-schema.org/draft-07/schema#",
|
|
84
|
+
$id: `${name}.schema.json`,
|
|
85
|
+
title: config.title,
|
|
86
|
+
description: config.description,
|
|
87
|
+
type: "object",
|
|
88
|
+
required: ["name", "props"],
|
|
89
|
+
properties: {
|
|
90
|
+
name: {
|
|
91
|
+
type: "string",
|
|
92
|
+
const: name,
|
|
93
|
+
description: `Component name identifier (must be "${name}")`
|
|
94
|
+
},
|
|
95
|
+
id: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "Optional unique identifier for the component"
|
|
98
|
+
},
|
|
99
|
+
props: JSON.parse(JSON.stringify(config.schema))
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
if (["docx", "section", "columns", "text-box"].includes(name)) {
|
|
103
|
+
componentStructure.properties.children = {
|
|
104
|
+
type: "array",
|
|
105
|
+
description: "Children within this container",
|
|
106
|
+
items: {
|
|
107
|
+
$ref: "#/definitions/ComponentDefinition"
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
if (componentDefinitionSchema) {
|
|
111
|
+
componentStructure.definitions = {
|
|
112
|
+
ComponentDefinition: JSON.parse(
|
|
113
|
+
JSON.stringify(componentDefinitionSchema)
|
|
114
|
+
)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (config.enhanceForRichContent && name === "table") {
|
|
119
|
+
const componentStructureWithDefs = componentStructure;
|
|
120
|
+
if (!componentStructureWithDefs.definitions) {
|
|
121
|
+
componentStructureWithDefs.definitions = {};
|
|
122
|
+
}
|
|
123
|
+
if (componentDefinitionSchema) {
|
|
124
|
+
componentStructureWithDefs.definitions.ComponentDefinition = JSON.parse(
|
|
125
|
+
JSON.stringify(componentDefinitionSchema)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const properties = componentStructure.properties;
|
|
129
|
+
const propsProp = properties.props;
|
|
130
|
+
if (propsProp?.properties && typeof propsProp.properties === "object" && propsProp.properties !== null) {
|
|
131
|
+
const propsProps = propsProp.properties;
|
|
132
|
+
const rowsProp = propsProps.rows;
|
|
133
|
+
if (rowsProp?.items && typeof rowsProp.items === "object" && rowsProp.items !== null) {
|
|
134
|
+
const rowsItems = rowsProp.items;
|
|
135
|
+
const cellSchema = rowsItems.items;
|
|
136
|
+
if (cellSchema?.anyOf && Array.isArray(cellSchema.anyOf)) {
|
|
137
|
+
const hasComponentRef = cellSchema.anyOf.some((item) => {
|
|
138
|
+
const itemObj = item;
|
|
139
|
+
return itemObj.$ref === "#/definitions/ComponentDefinition";
|
|
140
|
+
});
|
|
141
|
+
if (!hasComponentRef) {
|
|
142
|
+
cellSchema.anyOf.push({
|
|
143
|
+
description: "Rich content cell with component (e.g., image, paragraph)",
|
|
144
|
+
$ref: "#/definitions/ComponentDefinition"
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
fixSchemaReferences(componentStructure);
|
|
152
|
+
componentStructure.additionalProperties = false;
|
|
153
|
+
return componentStructure;
|
|
154
|
+
}
|
|
155
|
+
async function exportSchemaToFile(schema, outputPath, options = {}) {
|
|
156
|
+
const { prettyPrint = true } = options;
|
|
157
|
+
const jsonSchema = prettyPrint ? JSON.stringify(schema, null, 2) : JSON.stringify(schema);
|
|
158
|
+
const fs = await import("fs/promises");
|
|
159
|
+
await fs.writeFile(outputPath, jsonSchema, "utf-8");
|
|
160
|
+
}
|
|
161
|
+
var COMPONENT_METADATA = {
|
|
162
|
+
report: {
|
|
163
|
+
title: "Report Component",
|
|
164
|
+
description: "Top-level report container component with document-wide settings"
|
|
165
|
+
},
|
|
166
|
+
section: {
|
|
167
|
+
title: "Section Component",
|
|
168
|
+
description: "Section container for organizing document content"
|
|
169
|
+
},
|
|
170
|
+
columns: {
|
|
171
|
+
title: "Columns Component",
|
|
172
|
+
description: "Multi-column layout container"
|
|
173
|
+
},
|
|
174
|
+
heading: {
|
|
175
|
+
title: "Heading Component",
|
|
176
|
+
description: "Heading text with configurable levels and styling"
|
|
177
|
+
},
|
|
178
|
+
paragraph: {
|
|
179
|
+
title: "Paragraph Component",
|
|
180
|
+
description: "Rich paragraph text content with formatting options"
|
|
181
|
+
},
|
|
182
|
+
"text-box": {
|
|
183
|
+
title: "Text Box Component",
|
|
184
|
+
description: "Inline or floating container that groups text and image components with shared positioning"
|
|
185
|
+
},
|
|
186
|
+
image: {
|
|
187
|
+
title: "Image Component",
|
|
188
|
+
description: "Image content with positioning and sizing options"
|
|
189
|
+
},
|
|
190
|
+
statistic: {
|
|
191
|
+
title: "Statistic Component",
|
|
192
|
+
description: "Statistical display with value and label"
|
|
193
|
+
},
|
|
194
|
+
table: {
|
|
195
|
+
title: "Table Component",
|
|
196
|
+
description: "Tabular data display with headers and rows",
|
|
197
|
+
enhanceForRichContent: true
|
|
198
|
+
},
|
|
199
|
+
header: {
|
|
200
|
+
title: "Header Component",
|
|
201
|
+
description: "Document header with page numbering and metadata"
|
|
202
|
+
},
|
|
203
|
+
footer: {
|
|
204
|
+
title: "Footer Component",
|
|
205
|
+
description: "Document footer with page numbering and metadata"
|
|
206
|
+
},
|
|
207
|
+
list: {
|
|
208
|
+
title: "List Component",
|
|
209
|
+
description: "Ordered or unordered list with nested items"
|
|
210
|
+
},
|
|
211
|
+
highcharts: {
|
|
212
|
+
title: "Highcharts Component",
|
|
213
|
+
description: "Charts powered by Highcharts (line, bar, pie, heatmap, etc.) with rich configuration"
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var BASE_SCHEMA_METADATA = {
|
|
217
|
+
alignment: {
|
|
218
|
+
title: "Alignment",
|
|
219
|
+
description: "Text alignment options"
|
|
220
|
+
},
|
|
221
|
+
"base-component": {
|
|
222
|
+
title: "Base Component Props",
|
|
223
|
+
description: "Common props for all components"
|
|
224
|
+
},
|
|
225
|
+
border: {
|
|
226
|
+
title: "Border",
|
|
227
|
+
description: "Border styling configuration"
|
|
228
|
+
},
|
|
229
|
+
spacing: {
|
|
230
|
+
title: "Spacing",
|
|
231
|
+
description: "Spacing configuration for before and after elements"
|
|
232
|
+
},
|
|
233
|
+
margins: {
|
|
234
|
+
title: "Margins",
|
|
235
|
+
description: "Margin configuration for all sides"
|
|
236
|
+
},
|
|
237
|
+
indent: {
|
|
238
|
+
title: "Indent",
|
|
239
|
+
description: "Indentation configuration"
|
|
240
|
+
},
|
|
241
|
+
"line-spacing": {
|
|
242
|
+
title: "Line Spacing",
|
|
243
|
+
description: "Line height and spacing configuration"
|
|
244
|
+
},
|
|
245
|
+
"heading-level": {
|
|
246
|
+
title: "Heading Level",
|
|
247
|
+
description: "Heading level from 1 to 6"
|
|
248
|
+
},
|
|
249
|
+
numbering: {
|
|
250
|
+
title: "Numbering",
|
|
251
|
+
description: "Numbering configuration for ordered lists"
|
|
252
|
+
},
|
|
253
|
+
"justified-alignment": {
|
|
254
|
+
title: "Justified Alignment",
|
|
255
|
+
description: "Justified text alignment options"
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
var THEME_SCHEMA_METADATA = {
|
|
259
|
+
theme: {
|
|
260
|
+
title: "Theme Configuration",
|
|
261
|
+
description: "JSON theme configuration for document styling and appearance"
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export {
|
|
266
|
+
fixSchemaReferences,
|
|
267
|
+
convertToJsonSchema,
|
|
268
|
+
createComponentSchema,
|
|
269
|
+
exportSchemaToFile,
|
|
270
|
+
COMPONENT_METADATA,
|
|
271
|
+
BASE_SCHEMA_METADATA,
|
|
272
|
+
THEME_SCHEMA_METADATA
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=chunk-HHMK2RWF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/export.ts"],"sourcesContent":["/**\n * Unified Schema Export Utility\n *\n * Single source of truth for converting TypeBox schemas to JSON Schema format.\n * Eliminates duplication between generate-schemas.mjs and plugin/schema.ts\n */\n\nimport { TSchema } from '@sinclair/typebox';\n\n/**\n * Configuration for a component schema\n */\nexport interface ComponentSchemaConfig {\n schema: TSchema;\n title: string;\n description: string;\n requiresName?: boolean;\n enhanceForRichContent?: boolean;\n}\n\n/**\n * Fix TypeBox recursive references in a schema\n * Handles both \"T0\" and \"ComponentDefinition\" reference patterns\n */\nexport function fixSchemaReferences(\n schema: Record<string, unknown>,\n rootDefinitionName = 'ComponentDefinition'\n): void {\n function traverse(obj: Record<string, unknown>, path = ''): void {\n if (typeof obj !== 'object' || obj === null) return;\n\n for (const [key, value] of Object.entries(obj)) {\n const currentPath = path ? `${path}.${key}` : key;\n\n if (value && typeof value === 'object') {\n // Type guard to check if value has expected properties\n const schemaValue = value as Record<string, unknown>;\n\n // Fix arrays with empty items\n if (\n schemaValue.type === 'array' &&\n schemaValue.items &&\n Object.keys(schemaValue.items).length === 0\n ) {\n schemaValue.items = {\n $ref: `#/definitions/${rootDefinitionName}`,\n };\n }\n\n // Fix arrays with items that reference broken \"T0\"\n if (\n schemaValue.type === 'array' &&\n schemaValue.items &&\n typeof schemaValue.items === 'object' &&\n '$ref' in schemaValue.items &&\n (schemaValue.items as Record<string, unknown>).$ref === 'T0'\n ) {\n schemaValue.items = {\n $ref: `#/definitions/${rootDefinitionName}`,\n };\n }\n\n // Fix direct $ref properties that point to \"T0\" or bare definition names\n if (\n schemaValue.$ref === 'T0' ||\n schemaValue.$ref === rootDefinitionName\n ) {\n schemaValue.$ref = `#/definitions/${rootDefinitionName}`;\n }\n\n // Remove problematic $id properties that reference \"T0\"\n if (\n key === '$id' &&\n typeof value === 'string' &&\n (value === 'T0' || value === rootDefinitionName) &&\n currentPath !== `definitions.${rootDefinitionName}.$id`\n ) {\n delete obj[key];\n continue;\n }\n\n traverse(value as Record<string, unknown>, currentPath);\n }\n }\n }\n\n traverse(schema);\n}\n\n/**\n * Convert TypeBox schema to JSON Schema format with proper definitions\n */\nexport function convertToJsonSchema(\n schema: TSchema,\n options: {\n $schema?: string;\n $id?: string;\n title?: string;\n description?: string;\n definitions?: Record<string, unknown>;\n } = {}\n): Record<string, unknown> {\n const {\n $schema = 'https://json-schema.org/draft-07/schema#',\n $id,\n title,\n description,\n definitions = {},\n } = options;\n\n // Clone the schema to avoid mutations\n const schemaJson = JSON.parse(JSON.stringify(schema));\n\n // Extract recursive schemas to definitions\n const extractedDefinitions: Record<string, unknown> = { ...definitions };\n\n function extractRecursiveSchemas(\n obj: Record<string, unknown>,\n path = ''\n ): void {\n if (typeof obj !== 'object' || obj === null) return;\n\n for (const [key, value] of Object.entries(obj)) {\n if (value && typeof value === 'object') {\n const schemaValue = value as Record<string, unknown>;\n\n // If this schema has an $id, extract it to definitions\n if (schemaValue.$id && typeof schemaValue.$id === 'string') {\n const definitionName = schemaValue.$id;\n\n // Don't extract if it's already in the root definitions section\n if (path !== `definitions.${definitionName}`) {\n // Clone the schema without the $id\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { $id: _, ...schemaWithoutId } = schemaValue;\n extractedDefinitions[definitionName] = schemaWithoutId;\n\n // Replace the inline schema with a $ref\n obj[key] = { $ref: `#/definitions/${definitionName}` };\n\n // Continue processing the extracted schema for nested recursions\n extractRecursiveSchemas(\n schemaWithoutId,\n `definitions.${definitionName}`\n );\n continue;\n }\n }\n\n extractRecursiveSchemas(\n value as Record<string, unknown>,\n path ? `${path}.${key}` : key\n );\n }\n }\n }\n\n // Extract recursive schemas from the main schema\n extractRecursiveSchemas(schemaJson);\n\n // Build the final JSON Schema\n const jsonSchema: Record<string, unknown> = {\n $schema,\n };\n\n if ($id) jsonSchema.$id = $id;\n\n // Merge schema properties first to preserve original metadata\n Object.assign(jsonSchema, schemaJson);\n\n // Only override title and description if explicitly provided\n if (title !== undefined) jsonSchema.title = title;\n if (description !== undefined) jsonSchema.description = description;\n\n // Add definitions section if we have any\n if (Object.keys(extractedDefinitions).length > 0) {\n jsonSchema.definitions = extractedDefinitions;\n }\n\n // Fix any remaining recursive references\n fixSchemaReferences(jsonSchema);\n\n return jsonSchema;\n}\n\n/**\n * Create a component schema with proper structure\n */\nexport function createComponentSchema(\n name: string,\n config: ComponentSchemaConfig,\n componentDefinitionSchema?: TSchema\n): Record<string, unknown> {\n const componentStructure: Record<string, unknown> = {\n $schema: 'https://json-schema.org/draft-07/schema#',\n $id: `${name}.schema.json`,\n title: config.title,\n description: config.description,\n type: 'object',\n required: ['name', 'props'],\n properties: {\n name: {\n type: 'string',\n const: name,\n description: `Component name identifier (must be \"${name}\")`,\n },\n id: {\n type: 'string',\n description: 'Optional unique identifier for the component',\n },\n props: JSON.parse(JSON.stringify(config.schema)),\n },\n };\n\n // Add children array for container types\n if (['docx', 'section', 'columns', 'text-box'].includes(name)) {\n (componentStructure.properties as Record<string, unknown>).children = {\n type: 'array',\n description: 'Children within this container',\n items: {\n $ref: '#/definitions/ComponentDefinition',\n },\n };\n\n // Add the ComponentDefinition for recursive references\n if (componentDefinitionSchema) {\n componentStructure.definitions = {\n ComponentDefinition: JSON.parse(\n JSON.stringify(componentDefinitionSchema)\n ),\n };\n }\n }\n\n // Enhance table component to support rich content in cells\n if (config.enhanceForRichContent && name === 'table') {\n // Add ComponentDefinition to support rich content in table cells\n const componentStructureWithDefs = componentStructure as Record<\n string,\n unknown\n > & {\n definitions?: Record<string, unknown>;\n };\n if (!componentStructureWithDefs.definitions) {\n componentStructureWithDefs.definitions = {};\n }\n if (componentDefinitionSchema) {\n componentStructureWithDefs.definitions.ComponentDefinition = JSON.parse(\n JSON.stringify(componentDefinitionSchema)\n );\n }\n\n // Enhance the rows.items.items to support components\n const properties = componentStructure.properties as Record<string, unknown>;\n const propsProp = properties.props as Record<string, unknown> | undefined;\n if (\n propsProp?.properties &&\n typeof propsProp.properties === 'object' &&\n propsProp.properties !== null\n ) {\n const propsProps = propsProp.properties as Record<string, unknown>;\n const rowsProp = propsProps.rows as Record<string, unknown> | undefined;\n if (\n rowsProp?.items &&\n typeof rowsProp.items === 'object' &&\n rowsProp.items !== null\n ) {\n const rowsItems = rowsProp.items as Record<string, unknown>;\n const cellSchema = rowsItems.items as\n | Record<string, unknown>\n | undefined;\n\n // If it has anyOf, add component reference as an option\n if (cellSchema?.anyOf && Array.isArray(cellSchema.anyOf)) {\n // Check if component reference isn't already there\n const hasComponentRef = cellSchema.anyOf.some((item: unknown) => {\n const itemObj = item as Record<string, unknown>;\n return itemObj.$ref === '#/definitions/ComponentDefinition';\n });\n if (!hasComponentRef) {\n cellSchema.anyOf.push({\n description:\n 'Rich content cell with component (e.g., image, paragraph)',\n $ref: '#/definitions/ComponentDefinition',\n });\n }\n }\n }\n }\n }\n\n // Fix empty items in arrays and broken references\n fixSchemaReferences(componentStructure);\n\n componentStructure.additionalProperties = false;\n\n return componentStructure;\n}\n\n/**\n * Export schema to file with proper formatting\n */\nexport async function exportSchemaToFile(\n schema: Record<string, unknown>,\n outputPath: string,\n options: {\n prettyPrint?: boolean;\n } = {}\n): Promise<void> {\n const { prettyPrint = true } = options;\n\n // Convert to JSON string\n const jsonSchema = prettyPrint\n ? JSON.stringify(schema, null, 2)\n : JSON.stringify(schema);\n\n // Write to file\n const fs = await import('fs/promises');\n await fs.writeFile(outputPath, jsonSchema, 'utf-8');\n}\n\n/**\n * Component metadata registry\n * Single source of truth for component titles and descriptions\n */\nexport const COMPONENT_METADATA: Record<\n string,\n Omit<ComponentSchemaConfig, 'schema'>\n> = {\n report: {\n title: 'Report Component',\n description:\n 'Top-level report container component with document-wide settings',\n },\n section: {\n title: 'Section Component',\n description: 'Section container for organizing document content',\n },\n columns: {\n title: 'Columns Component',\n description: 'Multi-column layout container',\n },\n heading: {\n title: 'Heading Component',\n description: 'Heading text with configurable levels and styling',\n },\n paragraph: {\n title: 'Paragraph Component',\n description: 'Rich paragraph text content with formatting options',\n },\n 'text-box': {\n title: 'Text Box Component',\n description:\n 'Inline or floating container that groups text and image components with shared positioning',\n },\n image: {\n title: 'Image Component',\n description: 'Image content with positioning and sizing options',\n },\n statistic: {\n title: 'Statistic Component',\n description: 'Statistical display with value and label',\n },\n table: {\n title: 'Table Component',\n description: 'Tabular data display with headers and rows',\n enhanceForRichContent: true,\n },\n header: {\n title: 'Header Component',\n description: 'Document header with page numbering and metadata',\n },\n footer: {\n title: 'Footer Component',\n description: 'Document footer with page numbering and metadata',\n },\n list: {\n title: 'List Component',\n description: 'Ordered or unordered list with nested items',\n },\n highcharts: {\n title: 'Highcharts Component',\n description:\n 'Charts powered by Highcharts (line, bar, pie, heatmap, etc.) with rich configuration',\n },\n};\n\n/**\n * Base schema metadata registry\n */\nexport const BASE_SCHEMA_METADATA: Record<\n string,\n { title: string; description: string }\n> = {\n alignment: {\n title: 'Alignment',\n description: 'Text alignment options',\n },\n 'base-component': {\n title: 'Base Component Props',\n description: 'Common props for all components',\n },\n border: {\n title: 'Border',\n description: 'Border styling configuration',\n },\n spacing: {\n title: 'Spacing',\n description: 'Spacing configuration for before and after elements',\n },\n margins: {\n title: 'Margins',\n description: 'Margin configuration for all sides',\n },\n indent: {\n title: 'Indent',\n description: 'Indentation configuration',\n },\n 'line-spacing': {\n title: 'Line Spacing',\n description: 'Line height and spacing configuration',\n },\n 'heading-level': {\n title: 'Heading Level',\n description: 'Heading level from 1 to 6',\n },\n numbering: {\n title: 'Numbering',\n description: 'Numbering configuration for ordered lists',\n },\n 'justified-alignment': {\n title: 'Justified Alignment',\n description: 'Justified text alignment options',\n },\n};\n\n/**\n * Theme schema metadata\n */\nexport const THEME_SCHEMA_METADATA = {\n theme: {\n title: 'Theme Configuration',\n description: 'JSON theme configuration for document styling and appearance',\n },\n};\n"],"mappings":";AAwBO,SAAS,oBACd,QACA,qBAAqB,uBACf;AACN,WAAS,SAAS,KAA8B,OAAO,IAAU;AAC/D,QAAI,OAAO,QAAQ,YAAY,QAAQ,KAAM;AAE7C,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,YAAM,cAAc,OAAO,GAAG,IAAI,IAAI,GAAG,KAAK;AAE9C,UAAI,SAAS,OAAO,UAAU,UAAU;AAEtC,cAAM,cAAc;AAGpB,YACE,YAAY,SAAS,WACrB,YAAY,SACZ,OAAO,KAAK,YAAY,KAAK,EAAE,WAAW,GAC1C;AACA,sBAAY,QAAQ;AAAA,YAClB,MAAM,iBAAiB,kBAAkB;AAAA,UAC3C;AAAA,QACF;AAGA,YACE,YAAY,SAAS,WACrB,YAAY,SACZ,OAAO,YAAY,UAAU,YAC7B,UAAU,YAAY,SACrB,YAAY,MAAkC,SAAS,MACxD;AACA,sBAAY,QAAQ;AAAA,YAClB,MAAM,iBAAiB,kBAAkB;AAAA,UAC3C;AAAA,QACF;AAGA,YACE,YAAY,SAAS,QACrB,YAAY,SAAS,oBACrB;AACA,sBAAY,OAAO,iBAAiB,kBAAkB;AAAA,QACxD;AAGA,YACE,QAAQ,SACR,OAAO,UAAU,aAChB,UAAU,QAAQ,UAAU,uBAC7B,gBAAgB,eAAe,kBAAkB,QACjD;AACA,iBAAO,IAAI,GAAG;AACd;AAAA,QACF;AAEA,iBAAS,OAAkC,WAAW;AAAA,MACxD;AAAA,IACF;AAAA,EACF;AAEA,WAAS,MAAM;AACjB;AAKO,SAAS,oBACd,QACA,UAMI,CAAC,GACoB;AACzB,QAAM;AAAA,IACJ,UAAU;AAAA,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