@json-to-office/shared 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/cache/index.d.ts +464 -0
- package/dist/cache/index.js +738 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/chunk-244MHDOZ.js +39 -0
- package/dist/chunk-244MHDOZ.js.map +1 -0
- package/dist/chunk-5J43F4XD.js +181 -0
- package/dist/chunk-5J43F4XD.js.map +1 -0
- package/dist/chunk-ZKD5BAMU.js +382 -0
- package/dist/chunk-ZKD5BAMU.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-utils-CbCi6dEk.d.ts +43 -0
- package/dist/schemas/schema-utils.d.ts +2 -0
- package/dist/schemas/schema-utils.js +15 -0
- package/dist/schemas/schema-utils.js.map +1 -0
- package/dist/types/warnings.d.ts +9 -0
- package/dist/types/warnings.js +1 -0
- package/dist/types/warnings.js.map +1 -0
- package/dist/utils/semver.d.ts +11 -0
- package/dist/utils/semver.js +13 -0
- package/dist/utils/semver.js.map +1 -0
- package/dist/validation/unified/index.d.ts +66 -0
- package/dist/validation/unified/index.js +41 -0
- package/dist/validation/unified/index.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// src/validation/unified/schema-utils.ts
|
|
2
|
+
var componentNamesCache = /* @__PURE__ */ new Map();
|
|
3
|
+
function isUnionSchema(schema) {
|
|
4
|
+
return "anyOf" in schema && Array.isArray(schema.anyOf);
|
|
5
|
+
}
|
|
6
|
+
function isObjectSchema(schema) {
|
|
7
|
+
return schema.type === "object" && "properties" in schema;
|
|
8
|
+
}
|
|
9
|
+
function isLiteralSchema(schema) {
|
|
10
|
+
return "const" in schema;
|
|
11
|
+
}
|
|
12
|
+
function getObjectSchemaPropertyNames(schema) {
|
|
13
|
+
if (isObjectSchema(schema)) {
|
|
14
|
+
return Object.keys(schema.properties);
|
|
15
|
+
}
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
function getLiteralValue(schema) {
|
|
19
|
+
if (isLiteralSchema(schema)) {
|
|
20
|
+
return schema.const;
|
|
21
|
+
}
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
function extractStandardComponentNames(schema) {
|
|
25
|
+
if (componentNamesCache.has(schema)) {
|
|
26
|
+
return componentNamesCache.get(schema);
|
|
27
|
+
}
|
|
28
|
+
const names = [];
|
|
29
|
+
if ("anyOf" in schema && Array.isArray(schema.anyOf)) {
|
|
30
|
+
for (const componentSchema of schema.anyOf) {
|
|
31
|
+
if (isObjectSchema(componentSchema)) {
|
|
32
|
+
const nameProperty = componentSchema.properties?.name;
|
|
33
|
+
if (nameProperty && isLiteralSchema(nameProperty)) {
|
|
34
|
+
const nameValue = getLiteralValue(nameProperty);
|
|
35
|
+
if (typeof nameValue === "string") {
|
|
36
|
+
names.push(nameValue);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} else if (isObjectSchema(schema)) {
|
|
42
|
+
const nameProperty = schema.properties?.name ?? schema.properties?.type;
|
|
43
|
+
if (nameProperty && isLiteralSchema(nameProperty)) {
|
|
44
|
+
const nameValue = getLiteralValue(nameProperty);
|
|
45
|
+
if (typeof nameValue === "string") {
|
|
46
|
+
names.push(nameValue);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
componentNamesCache.set(schema, names);
|
|
51
|
+
return names;
|
|
52
|
+
}
|
|
53
|
+
function clearComponentNamesCache() {
|
|
54
|
+
componentNamesCache.clear();
|
|
55
|
+
}
|
|
56
|
+
function getSchemaMetadata(schema) {
|
|
57
|
+
const metadata = {};
|
|
58
|
+
if ("type" in schema) {
|
|
59
|
+
metadata.type = String(schema.type);
|
|
60
|
+
}
|
|
61
|
+
if (isObjectSchema(schema)) {
|
|
62
|
+
metadata.properties = getObjectSchemaPropertyNames(schema);
|
|
63
|
+
}
|
|
64
|
+
if (isLiteralSchema(schema)) {
|
|
65
|
+
metadata.literal = getLiteralValue(schema);
|
|
66
|
+
}
|
|
67
|
+
return metadata;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/validation/unified/error-formatter-config.ts
|
|
71
|
+
function isCI() {
|
|
72
|
+
if (typeof process === "undefined" || !process.env) return false;
|
|
73
|
+
return !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI);
|
|
74
|
+
}
|
|
75
|
+
function hasColorSupport() {
|
|
76
|
+
if (typeof process === "undefined") return false;
|
|
77
|
+
if (process.env?.NO_COLOR) return false;
|
|
78
|
+
if (process.env?.FORCE_COLOR) return true;
|
|
79
|
+
if (process.stdout?.isTTY) return true;
|
|
80
|
+
return !isCI();
|
|
81
|
+
}
|
|
82
|
+
var DEFAULT_ERROR_CONFIG = {
|
|
83
|
+
includeEmojis: !isCI(),
|
|
84
|
+
verbosity: "normal",
|
|
85
|
+
includeSuggestions: true,
|
|
86
|
+
includePath: true,
|
|
87
|
+
maxMessageLength: 0,
|
|
88
|
+
includeDocLinks: false,
|
|
89
|
+
colorSupport: hasColorSupport()
|
|
90
|
+
};
|
|
91
|
+
function createErrorConfig(config) {
|
|
92
|
+
return { ...DEFAULT_ERROR_CONFIG, ...config };
|
|
93
|
+
}
|
|
94
|
+
var ERROR_EMOJIS = {
|
|
95
|
+
ERROR: "\u274C",
|
|
96
|
+
WARNING: "\u26A0\uFE0F",
|
|
97
|
+
FIX: "\u{1F527}",
|
|
98
|
+
INFO: "\u2139\uFE0F",
|
|
99
|
+
SUCCESS: "\u2705"
|
|
100
|
+
};
|
|
101
|
+
function formatErrorMessage(message, config) {
|
|
102
|
+
if (config.maxMessageLength > 0 && message.length > config.maxMessageLength) {
|
|
103
|
+
return message.substring(0, config.maxMessageLength) + "...";
|
|
104
|
+
}
|
|
105
|
+
return message;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/validation/unified/error-transformer.ts
|
|
109
|
+
function generateEnhancedMessage(error, _config) {
|
|
110
|
+
const typeStr = String(error.type || "");
|
|
111
|
+
const path = error.path || "root";
|
|
112
|
+
if (typeStr === "62" || typeStr === "union") {
|
|
113
|
+
return generateUnionErrorMessage(error);
|
|
114
|
+
}
|
|
115
|
+
if (error.message?.includes("additionalProperties")) {
|
|
116
|
+
return generateAdditionalPropertiesMessage(error);
|
|
117
|
+
}
|
|
118
|
+
if (error.message?.includes("Required property")) {
|
|
119
|
+
return generateRequiredPropertyMessage(error);
|
|
120
|
+
}
|
|
121
|
+
if (typeStr === "string" || typeStr === "number" || typeStr === "boolean" || typeStr === "array" || typeStr === "object") {
|
|
122
|
+
return generateTypeMismatchMessage(error);
|
|
123
|
+
}
|
|
124
|
+
if (typeStr === "literal") {
|
|
125
|
+
return generateLiteralErrorMessage(error);
|
|
126
|
+
}
|
|
127
|
+
if (typeStr === "pattern" || typeStr === "RegExp") {
|
|
128
|
+
return generatePatternErrorMessage(error);
|
|
129
|
+
}
|
|
130
|
+
return `At ${path}: ${error.message}`;
|
|
131
|
+
}
|
|
132
|
+
function generateUnionErrorMessage(error) {
|
|
133
|
+
const path = error.path || "root";
|
|
134
|
+
const value = error.value;
|
|
135
|
+
if (path === "root" || path === "/" || path === "/jsonDefinition") {
|
|
136
|
+
if (value && typeof value === "object") {
|
|
137
|
+
if ("name" in value) {
|
|
138
|
+
return `Invalid component configuration for '${value.name}'. Check that all required fields are present.`;
|
|
139
|
+
}
|
|
140
|
+
if ("children" in value && Array.isArray(value.children)) {
|
|
141
|
+
return "Document is missing required 'name' field.";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return "Invalid document structure. Check required fields.";
|
|
145
|
+
}
|
|
146
|
+
if (path.includes("/children/")) {
|
|
147
|
+
if (value && typeof value === "object" && "name" in value) {
|
|
148
|
+
const componentType = value.name;
|
|
149
|
+
return `Invalid component configuration for type '${componentType}'. Check that all required fields are present and correctly formatted.`;
|
|
150
|
+
}
|
|
151
|
+
return 'Invalid component structure. Each component must have a "name" field and valid configuration.';
|
|
152
|
+
}
|
|
153
|
+
return `Value at ${path} doesn't match any of the expected formats. Check the structure and required fields.`;
|
|
154
|
+
}
|
|
155
|
+
function generateAdditionalPropertiesMessage(error) {
|
|
156
|
+
const path = error.path || "root";
|
|
157
|
+
const value = error.value;
|
|
158
|
+
if (typeof value === "object" && value !== null) {
|
|
159
|
+
const schema = error.schema;
|
|
160
|
+
if (schema && isObjectSchema(schema)) {
|
|
161
|
+
const knownProps = getObjectSchemaPropertyNames(schema);
|
|
162
|
+
const actualProps = Object.keys(value);
|
|
163
|
+
const unknownProps = actualProps.filter((p) => !knownProps.includes(p));
|
|
164
|
+
if (unknownProps.length > 0) {
|
|
165
|
+
return `Unknown properties at ${path}: ${unknownProps.join(", ")}. Allowed properties are: ${knownProps.join(", ")}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return `Additional properties not allowed at ${path}. Check for typos or unsupported fields.`;
|
|
170
|
+
}
|
|
171
|
+
function generateRequiredPropertyMessage(error) {
|
|
172
|
+
const path = error.path || "root";
|
|
173
|
+
const match = error.message?.match(/Required property '([^']+)'/);
|
|
174
|
+
if (match) {
|
|
175
|
+
const propName = match[1];
|
|
176
|
+
return `Missing required field '${propName}' at ${path}. This field is mandatory.`;
|
|
177
|
+
}
|
|
178
|
+
return `Missing required property at ${path}. Check that all mandatory fields are present.`;
|
|
179
|
+
}
|
|
180
|
+
function generateTypeMismatchMessage(error) {
|
|
181
|
+
const path = error.path || "root";
|
|
182
|
+
const expectedType = String(error.type);
|
|
183
|
+
const actualType = Array.isArray(error.value) ? "array" : typeof error.value;
|
|
184
|
+
if (path.includes("alignment")) {
|
|
185
|
+
return `Invalid alignment value at ${path}. Expected one of: left, center, right, justify`;
|
|
186
|
+
}
|
|
187
|
+
if (path.includes("color")) {
|
|
188
|
+
return `Invalid color value at ${path}. Use hex format (#RRGGBB), rgb(r,g,b), or a named color`;
|
|
189
|
+
}
|
|
190
|
+
if (path.includes("fontSize") || path.includes("size")) {
|
|
191
|
+
return `Invalid size value at ${path}. Expected a number (in points)`;
|
|
192
|
+
}
|
|
193
|
+
if (path.includes("margin") || path.includes("padding") || path.includes("spacing")) {
|
|
194
|
+
return `Invalid spacing value at ${path}. Expected a number or spacing object with top/bottom/left/right`;
|
|
195
|
+
}
|
|
196
|
+
return `Type mismatch at ${path}: Expected ${expectedType} but got ${actualType}`;
|
|
197
|
+
}
|
|
198
|
+
function generateLiteralErrorMessage(error) {
|
|
199
|
+
const path = error.path || "root";
|
|
200
|
+
const expected = error.schema ? JSON.stringify(getLiteralValue(error.schema)) : "specific value";
|
|
201
|
+
const actual = JSON.stringify(error.value);
|
|
202
|
+
return `Invalid value at ${path}: Expected exactly ${expected} but got ${actual}`;
|
|
203
|
+
}
|
|
204
|
+
function generatePatternErrorMessage(error) {
|
|
205
|
+
const path = error.path || "root";
|
|
206
|
+
if (path.includes("email")) {
|
|
207
|
+
return `Invalid email format at ${path}. Use format: user@example.com`;
|
|
208
|
+
}
|
|
209
|
+
if (path.includes("url") || path.includes("link")) {
|
|
210
|
+
return `Invalid URL format at ${path}. Use format: https://example.com`;
|
|
211
|
+
}
|
|
212
|
+
if (path.includes("date")) {
|
|
213
|
+
return `Invalid date format at ${path}. Use ISO format: YYYY-MM-DD`;
|
|
214
|
+
}
|
|
215
|
+
return `Value at ${path} doesn't match the required pattern`;
|
|
216
|
+
}
|
|
217
|
+
function transformValueError(error, jsonString, config) {
|
|
218
|
+
const formatterConfig = createErrorConfig(config);
|
|
219
|
+
const enhancedMessage = generateEnhancedMessage(error, formatterConfig);
|
|
220
|
+
const baseError = {
|
|
221
|
+
path: error.path || "root",
|
|
222
|
+
message: formatErrorMessage(
|
|
223
|
+
enhancedMessage || error.message,
|
|
224
|
+
formatterConfig
|
|
225
|
+
),
|
|
226
|
+
code: String(error.type || "validation_error"),
|
|
227
|
+
value: error.value
|
|
228
|
+
};
|
|
229
|
+
if (formatterConfig.includeSuggestions) {
|
|
230
|
+
const suggestion = getSuggestion(error, formatterConfig);
|
|
231
|
+
if (suggestion) {
|
|
232
|
+
baseError.suggestion = formatErrorMessage(suggestion, formatterConfig);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (jsonString && error.path) {
|
|
236
|
+
const position = calculatePosition(jsonString, error.path);
|
|
237
|
+
if (position) {
|
|
238
|
+
baseError.line = position.line;
|
|
239
|
+
baseError.column = position.column;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return baseError;
|
|
243
|
+
}
|
|
244
|
+
function transformValueErrors(errors, options) {
|
|
245
|
+
const maxErrors = options?.maxErrors ?? Number.MAX_SAFE_INTEGER;
|
|
246
|
+
const result = [];
|
|
247
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
248
|
+
for (const error of errors) {
|
|
249
|
+
if (result.length >= maxErrors) break;
|
|
250
|
+
const errorKey = `${error.path}:${error.type}`;
|
|
251
|
+
if (!seenPaths.has(errorKey)) {
|
|
252
|
+
seenPaths.add(errorKey);
|
|
253
|
+
result.push(transformValueError(error, options?.jsonString, void 0));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
function calculatePosition(jsonString, path) {
|
|
259
|
+
try {
|
|
260
|
+
const pathParts = path.split("/").filter(Boolean);
|
|
261
|
+
if (pathParts.length === 0) {
|
|
262
|
+
return { line: 1, column: 1 };
|
|
263
|
+
}
|
|
264
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
265
|
+
const searchPattern = `"${lastPart}"`;
|
|
266
|
+
const index = jsonString.indexOf(searchPattern);
|
|
267
|
+
if (index === -1) {
|
|
268
|
+
return { line: 1, column: 1 };
|
|
269
|
+
}
|
|
270
|
+
const beforeError = jsonString.substring(0, index);
|
|
271
|
+
const lines = beforeError.split("\n");
|
|
272
|
+
const line = lines.length;
|
|
273
|
+
const column = lines[lines.length - 1].length + 1;
|
|
274
|
+
return { line, column };
|
|
275
|
+
} catch {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function getSuggestion(error, _config) {
|
|
280
|
+
const { type, path } = error;
|
|
281
|
+
const typeStr = String(type);
|
|
282
|
+
if (typeStr === "62" || typeStr === "union") {
|
|
283
|
+
if (path === "root" || path === "/") {
|
|
284
|
+
return 'Ensure the document has proper structure with a root "name" field';
|
|
285
|
+
}
|
|
286
|
+
if (path?.includes("/children/")) {
|
|
287
|
+
return 'Check that the component has a valid "name" and all required fields';
|
|
288
|
+
}
|
|
289
|
+
return "Review the structure and ensure all required fields are present with correct types";
|
|
290
|
+
}
|
|
291
|
+
if (error.message?.includes("additionalProperties")) {
|
|
292
|
+
return "Remove any unknown or unsupported fields.";
|
|
293
|
+
}
|
|
294
|
+
if (error.message?.includes("Required property")) {
|
|
295
|
+
return "Add the missing required field to fix this error";
|
|
296
|
+
}
|
|
297
|
+
if (typeStr === "string") {
|
|
298
|
+
if (path?.includes("color")) {
|
|
299
|
+
return "Use a valid color format (hex: #RRGGBB, rgb: rgb(r,g,b), or named color)";
|
|
300
|
+
}
|
|
301
|
+
return "Provide a text string value";
|
|
302
|
+
}
|
|
303
|
+
if (typeStr === "number") {
|
|
304
|
+
return "Provide a numeric value";
|
|
305
|
+
}
|
|
306
|
+
if (typeStr === "boolean") {
|
|
307
|
+
return "Use true or false (without quotes)";
|
|
308
|
+
}
|
|
309
|
+
if (typeStr === "array") {
|
|
310
|
+
return "Provide an array of values using square brackets []";
|
|
311
|
+
}
|
|
312
|
+
if (typeStr === "object") {
|
|
313
|
+
return "Provide an object with key-value pairs using curly braces {}";
|
|
314
|
+
}
|
|
315
|
+
if (typeStr === "literal") {
|
|
316
|
+
const expected = error.schema ? JSON.stringify(getLiteralValue(error.schema)) : "specific value";
|
|
317
|
+
return `Use exactly this value: ${expected}`;
|
|
318
|
+
}
|
|
319
|
+
return void 0;
|
|
320
|
+
}
|
|
321
|
+
function formatErrorSummary(errors) {
|
|
322
|
+
if (errors.length === 0) return "No errors";
|
|
323
|
+
if (errors.length === 1) {
|
|
324
|
+
return errors[0].message;
|
|
325
|
+
}
|
|
326
|
+
const summary = errors.slice(0, 3).map((e) => `${e.path}: ${e.message}`).join(", ");
|
|
327
|
+
if (errors.length > 3) {
|
|
328
|
+
return `${summary} and ${errors.length - 3} more...`;
|
|
329
|
+
}
|
|
330
|
+
return summary;
|
|
331
|
+
}
|
|
332
|
+
function groupErrorsByPath(errors) {
|
|
333
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
334
|
+
for (const error of errors) {
|
|
335
|
+
const path = error.path || "root";
|
|
336
|
+
const group = grouped.get(path) || [];
|
|
337
|
+
group.push(error);
|
|
338
|
+
grouped.set(path, group);
|
|
339
|
+
}
|
|
340
|
+
return grouped;
|
|
341
|
+
}
|
|
342
|
+
function createJsonParseError(error, jsonString) {
|
|
343
|
+
const match = error.message.match(/position (\d+)/);
|
|
344
|
+
const position = match ? parseInt(match[1], 10) : 0;
|
|
345
|
+
let line = 1;
|
|
346
|
+
let column = 1;
|
|
347
|
+
if (position > 0) {
|
|
348
|
+
const lines = jsonString.substring(0, position).split("\n");
|
|
349
|
+
line = lines.length;
|
|
350
|
+
column = lines[lines.length - 1].length + 1;
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
path: "root",
|
|
354
|
+
message: `JSON Parse Error: ${error.message}`,
|
|
355
|
+
code: "json_parse_error",
|
|
356
|
+
line,
|
|
357
|
+
column,
|
|
358
|
+
suggestion: "Check for missing commas, quotes, or brackets"
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export {
|
|
363
|
+
isUnionSchema,
|
|
364
|
+
isObjectSchema,
|
|
365
|
+
isLiteralSchema,
|
|
366
|
+
getObjectSchemaPropertyNames,
|
|
367
|
+
getLiteralValue,
|
|
368
|
+
extractStandardComponentNames,
|
|
369
|
+
clearComponentNamesCache,
|
|
370
|
+
getSchemaMetadata,
|
|
371
|
+
DEFAULT_ERROR_CONFIG,
|
|
372
|
+
createErrorConfig,
|
|
373
|
+
ERROR_EMOJIS,
|
|
374
|
+
formatErrorMessage,
|
|
375
|
+
transformValueError,
|
|
376
|
+
transformValueErrors,
|
|
377
|
+
calculatePosition,
|
|
378
|
+
formatErrorSummary,
|
|
379
|
+
groupErrorsByPath,
|
|
380
|
+
createJsonParseError
|
|
381
|
+
};
|
|
382
|
+
//# sourceMappingURL=chunk-ZKD5BAMU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/validation/unified/schema-utils.ts","../src/validation/unified/error-formatter-config.ts","../src/validation/unified/error-transformer.ts"],"sourcesContent":["import type { TSchema, TUnion, TObject, TLiteral } from '@sinclair/typebox';\n\nconst componentNamesCache = new Map<unknown, string[]>();\n\nexport function isUnionSchema(schema: TSchema): schema is TUnion {\n return 'anyOf' in schema && Array.isArray(schema.anyOf);\n}\n\nexport function isObjectSchema(schema: TSchema): schema is TObject {\n return schema.type === 'object' && 'properties' in schema;\n}\n\nexport function isLiteralSchema(schema: TSchema): schema is TLiteral {\n return 'const' in schema;\n}\n\nexport function getObjectSchemaPropertyNames(schema: TSchema): string[] {\n if (isObjectSchema(schema)) {\n return Object.keys(schema.properties);\n }\n return [];\n}\n\nexport function getLiteralValue(schema: TSchema): unknown {\n if (isLiteralSchema(schema)) {\n return schema.const;\n }\n return undefined;\n}\n\nexport function extractStandardComponentNames(schema: TSchema): string[] {\n if (componentNamesCache.has(schema)) {\n return componentNamesCache.get(schema)!;\n }\n\n const names: string[] = [];\n\n if ('anyOf' in schema && Array.isArray(schema.anyOf)) {\n for (const componentSchema of schema.anyOf) {\n if (isObjectSchema(componentSchema)) {\n const nameProperty = componentSchema.properties?.name;\n if (nameProperty && isLiteralSchema(nameProperty)) {\n const nameValue = getLiteralValue(nameProperty);\n if (typeof nameValue === 'string') {\n names.push(nameValue);\n }\n }\n }\n }\n } else if (isObjectSchema(schema)) {\n const nameProperty = schema.properties?.name ?? schema.properties?.type;\n if (nameProperty && isLiteralSchema(nameProperty)) {\n const nameValue = getLiteralValue(nameProperty);\n if (typeof nameValue === 'string') {\n names.push(nameValue);\n }\n }\n }\n\n componentNamesCache.set(schema, names);\n return names;\n}\n\nexport function clearComponentNamesCache(): void {\n componentNamesCache.clear();\n}\n\nexport function getSchemaMetadata(schema: TSchema): {\n type?: string;\n properties?: string[];\n literal?: unknown;\n} {\n const metadata: {\n type?: string;\n properties?: string[];\n literal?: unknown;\n } = {};\n\n if ('type' in schema) {\n metadata.type = String(schema.type);\n }\n\n if (isObjectSchema(schema)) {\n metadata.properties = getObjectSchemaPropertyNames(schema);\n }\n\n if (isLiteralSchema(schema)) {\n metadata.literal = getLiteralValue(schema);\n }\n\n return metadata;\n}\n","export interface ErrorFormatterConfig {\n includeEmojis?: boolean;\n verbosity?: 'minimal' | 'normal' | 'detailed';\n includeSuggestions?: boolean;\n includePath?: boolean;\n maxMessageLength?: number;\n includeDocLinks?: boolean;\n colorSupport?: boolean;\n}\n\nfunction isCI(): boolean {\n if (typeof process === 'undefined' || !process.env) return false;\n return !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI);\n}\n\nfunction hasColorSupport(): boolean {\n if (typeof process === 'undefined') return false;\n if (process.env?.NO_COLOR) return false;\n if (process.env?.FORCE_COLOR) return true;\n if (process.stdout?.isTTY) return true;\n return !isCI();\n}\n\nexport const DEFAULT_ERROR_CONFIG: Required<ErrorFormatterConfig> = {\n includeEmojis: !isCI(),\n verbosity: 'normal',\n includeSuggestions: true,\n includePath: true,\n maxMessageLength: 0,\n includeDocLinks: false,\n colorSupport: hasColorSupport(),\n};\n\nexport function createErrorConfig(\n config?: ErrorFormatterConfig\n): Required<ErrorFormatterConfig> {\n return { ...DEFAULT_ERROR_CONFIG, ...config };\n}\n\nexport const ERROR_EMOJIS = {\n ERROR: '\\u274c',\n WARNING: '\\u26a0\\ufe0f',\n FIX: '\\ud83d\\udd27',\n INFO: '\\u2139\\ufe0f',\n SUCCESS: '\\u2705',\n};\n\nexport function formatErrorMessage(\n message: string,\n config: Required<ErrorFormatterConfig>\n): string {\n if (config.maxMessageLength > 0 && message.length > config.maxMessageLength) {\n return message.substring(0, config.maxMessageLength) + '...';\n }\n return message;\n}\n","import type { ValueError } from '@sinclair/typebox/value';\nimport type { ValidationError } from './types';\nimport {\n isObjectSchema,\n getObjectSchemaPropertyNames,\n getLiteralValue,\n} from './schema-utils';\nimport {\n ErrorFormatterConfig,\n createErrorConfig,\n formatErrorMessage,\n} from './error-formatter-config';\n\nexport type { TransformedError } from './types';\n\nfunction generateEnhancedMessage(\n error: ValueError,\n _config: Required<ErrorFormatterConfig>\n): string {\n const typeStr = String(error.type || '');\n const path = error.path || 'root';\n\n if (typeStr === '62' || typeStr === 'union') {\n return generateUnionErrorMessage(error);\n }\n\n if (error.message?.includes('additionalProperties')) {\n return generateAdditionalPropertiesMessage(error);\n }\n\n if (error.message?.includes('Required property')) {\n return generateRequiredPropertyMessage(error);\n }\n\n if (\n typeStr === 'string' ||\n typeStr === 'number' ||\n typeStr === 'boolean' ||\n typeStr === 'array' ||\n typeStr === 'object'\n ) {\n return generateTypeMismatchMessage(error);\n }\n\n if (typeStr === 'literal') {\n return generateLiteralErrorMessage(error);\n }\n\n if (typeStr === 'pattern' || typeStr === 'RegExp') {\n return generatePatternErrorMessage(error);\n }\n\n return `At ${path}: ${error.message}`;\n}\n\nfunction generateUnionErrorMessage(error: ValueError): string {\n const path = error.path || 'root';\n const value = error.value;\n\n if (path === 'root' || path === '/' || path === '/jsonDefinition') {\n if (value && typeof value === 'object') {\n if ('name' in value) {\n return `Invalid component configuration for '${(value as any).name}'. Check that all required fields are present.`;\n }\n if ('children' in value && Array.isArray((value as any).children)) {\n return 'Document is missing required \\'name\\' field.';\n }\n }\n return 'Invalid document structure. Check required fields.';\n }\n\n if (path.includes('/children/')) {\n if (value && typeof value === 'object' && 'name' in value) {\n const componentType = (value as any).name;\n return `Invalid component configuration for type '${componentType}'. Check that all required fields are present and correctly formatted.`;\n }\n return 'Invalid component structure. Each component must have a \"name\" field and valid configuration.';\n }\n\n return `Value at ${path} doesn't match any of the expected formats. Check the structure and required fields.`;\n}\n\nfunction generateAdditionalPropertiesMessage(error: ValueError): string {\n const path = error.path || 'root';\n const value = error.value;\n\n if (typeof value === 'object' && value !== null) {\n const schema = error.schema;\n if (schema && isObjectSchema(schema)) {\n const knownProps = getObjectSchemaPropertyNames(schema);\n const actualProps = Object.keys(value);\n const unknownProps = actualProps.filter((p) => !knownProps.includes(p));\n\n if (unknownProps.length > 0) {\n return (\n `Unknown properties at ${path}: ${unknownProps.join(', ')}. ` +\n `Allowed properties are: ${knownProps.join(', ')}`\n );\n }\n }\n }\n\n return `Additional properties not allowed at ${path}. Check for typos or unsupported fields.`;\n}\n\nfunction generateRequiredPropertyMessage(error: ValueError): string {\n const path = error.path || 'root';\n const match = error.message?.match(/Required property '([^']+)'/);\n\n if (match) {\n const propName = match[1];\n return `Missing required field '${propName}' at ${path}. This field is mandatory.`;\n }\n\n return `Missing required property at ${path}. Check that all mandatory fields are present.`;\n}\n\nfunction generateTypeMismatchMessage(error: ValueError): string {\n const path = error.path || 'root';\n const expectedType = String(error.type);\n const actualType = Array.isArray(error.value) ? 'array' : typeof error.value;\n\n if (path.includes('alignment')) {\n return `Invalid alignment value at ${path}. Expected one of: left, center, right, justify`;\n }\n\n if (path.includes('color')) {\n return `Invalid color value at ${path}. Use hex format (#RRGGBB), rgb(r,g,b), or a named color`;\n }\n\n if (path.includes('fontSize') || path.includes('size')) {\n return `Invalid size value at ${path}. Expected a number (in points)`;\n }\n\n if (\n path.includes('margin') ||\n path.includes('padding') ||\n path.includes('spacing')\n ) {\n return `Invalid spacing value at ${path}. Expected a number or spacing object with top/bottom/left/right`;\n }\n\n return `Type mismatch at ${path}: Expected ${expectedType} but got ${actualType}`;\n}\n\nfunction generateLiteralErrorMessage(error: ValueError): string {\n const path = error.path || 'root';\n const expected = error.schema\n ? JSON.stringify(getLiteralValue(error.schema))\n : 'specific value';\n const actual = JSON.stringify(error.value);\n\n return `Invalid value at ${path}: Expected exactly ${expected} but got ${actual}`;\n}\n\nfunction generatePatternErrorMessage(error: ValueError): string {\n const path = error.path || 'root';\n\n if (path.includes('email')) {\n return `Invalid email format at ${path}. Use format: user@example.com`;\n }\n if (path.includes('url') || path.includes('link')) {\n return `Invalid URL format at ${path}. Use format: https://example.com`;\n }\n if (path.includes('date')) {\n return `Invalid date format at ${path}. Use ISO format: YYYY-MM-DD`;\n }\n\n return `Value at ${path} doesn't match the required pattern`;\n}\n\nexport function transformValueError(\n error: ValueError,\n jsonString?: string,\n config?: ErrorFormatterConfig\n): ValidationError {\n const formatterConfig = createErrorConfig(config);\n\n const enhancedMessage = generateEnhancedMessage(error, formatterConfig);\n\n const baseError: ValidationError = {\n path: error.path || 'root',\n message: formatErrorMessage(\n enhancedMessage || error.message,\n formatterConfig\n ),\n code: String(error.type || 'validation_error'),\n value: error.value,\n };\n\n if (formatterConfig.includeSuggestions) {\n const suggestion = getSuggestion(error, formatterConfig);\n if (suggestion) {\n baseError.suggestion = formatErrorMessage(suggestion, formatterConfig);\n }\n }\n\n if (jsonString && error.path) {\n const position = calculatePosition(jsonString, error.path);\n if (position) {\n baseError.line = position.line;\n baseError.column = position.column;\n }\n }\n\n return baseError;\n}\n\nexport function transformValueErrors(\n errors: ValueError[],\n options?: {\n jsonString?: string;\n maxErrors?: number;\n }\n): ValidationError[] {\n const maxErrors = options?.maxErrors ?? Number.MAX_SAFE_INTEGER;\n const result: ValidationError[] = [];\n const seenPaths = new Set<string>();\n\n for (const error of errors) {\n if (result.length >= maxErrors) break;\n\n const errorKey = `${error.path}:${error.type}`;\n\n if (!seenPaths.has(errorKey)) {\n seenPaths.add(errorKey);\n result.push(transformValueError(error, options?.jsonString, undefined));\n }\n }\n\n return result;\n}\n\nexport function calculatePosition(\n jsonString: string,\n path: string\n): { line: number; column: number } | null {\n try {\n const pathParts = path.split('/').filter(Boolean);\n if (pathParts.length === 0) {\n return { line: 1, column: 1 };\n }\n\n const lastPart = pathParts[pathParts.length - 1];\n const searchPattern = `\"${lastPart}\"`;\n const index = jsonString.indexOf(searchPattern);\n\n if (index === -1) {\n return { line: 1, column: 1 };\n }\n\n const beforeError = jsonString.substring(0, index);\n const lines = beforeError.split('\\n');\n const line = lines.length;\n const column = lines[lines.length - 1].length + 1;\n\n return { line, column };\n } catch {\n return null;\n }\n}\n\nfunction getSuggestion(\n error: ValueError,\n _config: Required<ErrorFormatterConfig>\n): string | undefined {\n const { type, path } = error;\n const typeStr = String(type);\n\n if (typeStr === '62' || typeStr === 'union') {\n if (path === 'root' || path === '/') {\n return 'Ensure the document has proper structure with a root \"name\" field';\n }\n if (path?.includes('/children/')) {\n return 'Check that the component has a valid \"name\" and all required fields';\n }\n return 'Review the structure and ensure all required fields are present with correct types';\n }\n\n if (error.message?.includes('additionalProperties')) {\n return 'Remove any unknown or unsupported fields.';\n }\n\n if (error.message?.includes('Required property')) {\n return 'Add the missing required field to fix this error';\n }\n\n if (typeStr === 'string') {\n if (path?.includes('color')) {\n return 'Use a valid color format (hex: #RRGGBB, rgb: rgb(r,g,b), or named color)';\n }\n return 'Provide a text string value';\n }\n\n if (typeStr === 'number') {\n return 'Provide a numeric value';\n }\n\n if (typeStr === 'boolean') {\n return 'Use true or false (without quotes)';\n }\n\n if (typeStr === 'array') {\n return 'Provide an array of values using square brackets []';\n }\n\n if (typeStr === 'object') {\n return 'Provide an object with key-value pairs using curly braces {}';\n }\n\n if (typeStr === 'literal') {\n const expected = error.schema\n ? JSON.stringify(getLiteralValue(error.schema))\n : 'specific value';\n return `Use exactly this value: ${expected}`;\n }\n\n return undefined;\n}\n\nexport function formatErrorSummary(errors: ValidationError[]): string {\n if (errors.length === 0) return 'No errors';\n\n if (errors.length === 1) {\n return errors[0].message;\n }\n\n const summary = errors\n .slice(0, 3)\n .map((e) => `${e.path}: ${e.message}`)\n .join(', ');\n\n if (errors.length > 3) {\n return `${summary} and ${errors.length - 3} more...`;\n }\n\n return summary;\n}\n\nexport function groupErrorsByPath(\n errors: ValidationError[]\n): Map<string, ValidationError[]> {\n const grouped = new Map<string, ValidationError[]>();\n\n for (const error of errors) {\n const path = error.path || 'root';\n const group = grouped.get(path) || [];\n group.push(error);\n grouped.set(path, group);\n }\n\n return grouped;\n}\n\nexport function createJsonParseError(\n error: Error,\n jsonString: string\n): ValidationError {\n const match = error.message.match(/position (\\d+)/);\n const position = match ? parseInt(match[1], 10) : 0;\n\n let line = 1;\n let column = 1;\n\n if (position > 0) {\n const lines = jsonString.substring(0, position).split('\\n');\n line = lines.length;\n column = lines[lines.length - 1].length + 1;\n }\n\n return {\n path: 'root',\n message: `JSON Parse Error: ${error.message}`,\n code: 'json_parse_error',\n line,\n column,\n suggestion: 'Check for missing commas, quotes, or brackets',\n };\n}\n"],"mappings":";AAEA,IAAM,sBAAsB,oBAAI,IAAuB;AAEhD,SAAS,cAAc,QAAmC;AAC/D,SAAO,WAAW,UAAU,MAAM,QAAQ,OAAO,KAAK;AACxD;AAEO,SAAS,eAAe,QAAoC;AACjE,SAAO,OAAO,SAAS,YAAY,gBAAgB;AACrD;AAEO,SAAS,gBAAgB,QAAqC;AACnE,SAAO,WAAW;AACpB;AAEO,SAAS,6BAA6B,QAA2B;AACtE,MAAI,eAAe,MAAM,GAAG;AAC1B,WAAO,OAAO,KAAK,OAAO,UAAU;AAAA,EACtC;AACA,SAAO,CAAC;AACV;AAEO,SAAS,gBAAgB,QAA0B;AACxD,MAAI,gBAAgB,MAAM,GAAG;AAC3B,WAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACT;AAEO,SAAS,8BAA8B,QAA2B;AACvE,MAAI,oBAAoB,IAAI,MAAM,GAAG;AACnC,WAAO,oBAAoB,IAAI,MAAM;AAAA,EACvC;AAEA,QAAM,QAAkB,CAAC;AAEzB,MAAI,WAAW,UAAU,MAAM,QAAQ,OAAO,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@@
|
|
|
1
|
+
export { C as ComponentDefinition, a as ComponentSchemaConfig, c as convertToJsonSchema, b as createComponentSchema, d as createComponentSchemaObject, e as exportSchemaToFile, f as fixSchemaReferences } from './schema-utils-CbCi6dEk.js';
|
|
2
|
+
export { AddWarningFunction, GenerationWarning } from './types/warnings.js';
|
|
3
|
+
export { DEFAULT_ERROR_CONFIG, ERROR_EMOJIS, ErrorFormatterConfig, TransformedError, ValidationError, ValidationResult, calculatePosition, clearComponentNamesCache, createErrorConfig, createJsonParseError, extractStandardComponentNames, formatErrorMessage, formatErrorSummary, getLiteralValue, getObjectSchemaPropertyNames, getSchemaMetadata, groupErrorsByPath, isLiteralSchema, isObjectSchema, isUnionSchema, transformValueError, transformValueErrors } from './validation/unified/index.js';
|
|
4
|
+
export { ParsedSemver, compareSemver, isValidSemver, latestVersion, parseSemver } from './utils/semver.js';
|
|
5
|
+
import '@sinclair/typebox';
|
|
6
|
+
import '@sinclair/typebox/value';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertToJsonSchema,
|
|
3
|
+
createComponentSchema,
|
|
4
|
+
createComponentSchemaObject,
|
|
5
|
+
exportSchemaToFile,
|
|
6
|
+
fixSchemaReferences
|
|
7
|
+
} from "./chunk-5J43F4XD.js";
|
|
8
|
+
import {
|
|
9
|
+
compareSemver,
|
|
10
|
+
isValidSemver,
|
|
11
|
+
latestVersion,
|
|
12
|
+
parseSemver
|
|
13
|
+
} from "./chunk-244MHDOZ.js";
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_ERROR_CONFIG,
|
|
16
|
+
ERROR_EMOJIS,
|
|
17
|
+
calculatePosition,
|
|
18
|
+
clearComponentNamesCache,
|
|
19
|
+
createErrorConfig,
|
|
20
|
+
createJsonParseError,
|
|
21
|
+
extractStandardComponentNames,
|
|
22
|
+
formatErrorMessage,
|
|
23
|
+
formatErrorSummary,
|
|
24
|
+
getLiteralValue,
|
|
25
|
+
getObjectSchemaPropertyNames,
|
|
26
|
+
getSchemaMetadata,
|
|
27
|
+
groupErrorsByPath,
|
|
28
|
+
isLiteralSchema,
|
|
29
|
+
isObjectSchema,
|
|
30
|
+
isUnionSchema,
|
|
31
|
+
transformValueError,
|
|
32
|
+
transformValueErrors
|
|
33
|
+
} from "./chunk-ZKD5BAMU.js";
|
|
34
|
+
export {
|
|
35
|
+
DEFAULT_ERROR_CONFIG,
|
|
36
|
+
ERROR_EMOJIS,
|
|
37
|
+
calculatePosition,
|
|
38
|
+
clearComponentNamesCache,
|
|
39
|
+
compareSemver,
|
|
40
|
+
convertToJsonSchema,
|
|
41
|
+
createComponentSchema,
|
|
42
|
+
createComponentSchemaObject,
|
|
43
|
+
createErrorConfig,
|
|
44
|
+
createJsonParseError,
|
|
45
|
+
exportSchemaToFile,
|
|
46
|
+
extractStandardComponentNames,
|
|
47
|
+
fixSchemaReferences,
|
|
48
|
+
formatErrorMessage,
|
|
49
|
+
formatErrorSummary,
|
|
50
|
+
getLiteralValue,
|
|
51
|
+
getObjectSchemaPropertyNames,
|
|
52
|
+
getSchemaMetadata,
|
|
53
|
+
groupErrorsByPath,
|
|
54
|
+
isLiteralSchema,
|
|
55
|
+
isObjectSchema,
|
|
56
|
+
isUnionSchema,
|
|
57
|
+
isValidSemver,
|
|
58
|
+
latestVersion,
|
|
59
|
+
parseSemver,
|
|
60
|
+
transformValueError,
|
|
61
|
+
transformValueErrors
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TSchema } from '@sinclair/typebox';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base component definition interface, parameterized by category.
|
|
5
|
+
* Both docx and pptx component registries extend this.
|
|
6
|
+
*/
|
|
7
|
+
interface ComponentDefinition<TCategory extends string = 'container' | 'content' | 'layout'> {
|
|
8
|
+
name: string;
|
|
9
|
+
propsSchema: TSchema;
|
|
10
|
+
hasChildren: boolean;
|
|
11
|
+
category: TCategory;
|
|
12
|
+
description: string;
|
|
13
|
+
special?: {
|
|
14
|
+
hasSchemaField?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ComponentSchemaConfig {
|
|
19
|
+
schema: TSchema;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
requiresName?: boolean;
|
|
23
|
+
enhanceForRichContent?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare function fixSchemaReferences(schema: Record<string, unknown>, rootDefinitionName?: string): void;
|
|
26
|
+
declare function convertToJsonSchema(schema: TSchema, options?: {
|
|
27
|
+
$schema?: string;
|
|
28
|
+
$id?: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
definitions?: Record<string, unknown>;
|
|
32
|
+
}): Record<string, unknown>;
|
|
33
|
+
declare function createComponentSchema(name: string, config: ComponentSchemaConfig, containerNames: string[], componentDefinitionSchema?: TSchema): Record<string, unknown>;
|
|
34
|
+
declare function exportSchemaToFile(schema: Record<string, unknown>, outputPath: string, options?: {
|
|
35
|
+
prettyPrint?: boolean;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Create a TypeBox schema object for any component definition.
|
|
39
|
+
* Works for both docx and pptx components.
|
|
40
|
+
*/
|
|
41
|
+
declare function createComponentSchemaObject(component: ComponentDefinition, recursiveRef?: TSchema): TSchema;
|
|
42
|
+
|
|
43
|
+
export { type ComponentDefinition as C, type ComponentSchemaConfig as a, createComponentSchema as b, convertToJsonSchema as c, createComponentSchemaObject as d, exportSchemaToFile as e, fixSchemaReferences as f };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
convertToJsonSchema,
|
|
3
|
+
createComponentSchema,
|
|
4
|
+
createComponentSchemaObject,
|
|
5
|
+
exportSchemaToFile,
|
|
6
|
+
fixSchemaReferences
|
|
7
|
+
} from "../chunk-5J43F4XD.js";
|
|
8
|
+
export {
|
|
9
|
+
convertToJsonSchema,
|
|
10
|
+
createComponentSchema,
|
|
11
|
+
createComponentSchemaObject,
|
|
12
|
+
exportSchemaToFile,
|
|
13
|
+
fixSchemaReferences
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=schema-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface GenerationWarning {
|
|
2
|
+
component: string;
|
|
3
|
+
message: string;
|
|
4
|
+
severity?: 'warning' | 'info';
|
|
5
|
+
context?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
type AddWarningFunction = (message: string, context?: Record<string, unknown>) => void;
|
|
8
|
+
|
|
9
|
+
export type { AddWarningFunction, GenerationWarning };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=warnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ParsedSemver {
|
|
2
|
+
major: number;
|
|
3
|
+
minor: number;
|
|
4
|
+
patch: number;
|
|
5
|
+
}
|
|
6
|
+
declare function isValidSemver(version: string): boolean;
|
|
7
|
+
declare function parseSemver(version: string): ParsedSemver;
|
|
8
|
+
declare function compareSemver(a: string, b: string): number;
|
|
9
|
+
declare function latestVersion(versions: string[]): string;
|
|
10
|
+
|
|
11
|
+
export { type ParsedSemver, compareSemver, isValidSemver, latestVersion, parseSemver };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|