@famgia/omnify-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,2018 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Omnify: () => Omnify,
34
+ OmnifyError: () => OmnifyError,
35
+ PluginManager: () => PluginManager,
36
+ atlasError: () => atlasError,
37
+ atlasNotFoundError: () => atlasNotFoundError,
38
+ circularReferenceError: () => circularReferenceError,
39
+ configError: () => configError,
40
+ configNotFoundError: () => configNotFoundError,
41
+ createOmnify: () => createOmnify,
42
+ createPluginManager: () => createPluginManager,
43
+ duplicateSchemaError: () => duplicateSchemaError,
44
+ err: () => import_omnify_types.err,
45
+ expandProperty: () => expandProperty,
46
+ expandSchema: () => expandSchema,
47
+ expandSchemaProperties: () => expandSchemaProperties,
48
+ expandSchemas: () => expandSchemas,
49
+ fileNameToSchemaName: () => fileNameToSchemaName,
50
+ findReferencedSchemas: () => findReferencedSchemas,
51
+ findReferencingSchemas: () => findReferencingSchemas,
52
+ formatError: () => formatError,
53
+ formatErrorPlain: () => formatErrorPlain,
54
+ formatErrorSummary: () => formatErrorSummary,
55
+ generationError: () => generationError,
56
+ getAssociationMetadata: () => getAssociationMetadata,
57
+ getCustomTypeNames: () => getCustomTypeNames,
58
+ getEntitySchemas: () => getEntitySchemas,
59
+ getEnumSchemas: () => getEnumSchemas,
60
+ getExitCode: () => getExitCode,
61
+ getGroups: () => getGroups,
62
+ getPropertyMetadata: () => getPropertyMetadata,
63
+ getRelationshipGraph: () => getRelationshipGraph,
64
+ getSchemaMetadata: () => getSchemaMetadata,
65
+ getSchemaNames: () => getSchemaNames,
66
+ getSchemasByGroup: () => getSchemasByGroup,
67
+ getSchemasByKind: () => getSchemasByKind,
68
+ getTopologicalOrder: () => getTopologicalOrder,
69
+ getTypeInfo: () => getTypeInfo,
70
+ hasCircularReferences: () => hasCircularReferences,
71
+ internalError: () => internalError,
72
+ introspectSchema: () => introspectSchema,
73
+ introspectSchemas: () => introspectSchemas,
74
+ invalidAssociationTargetError: () => invalidAssociationTargetError,
75
+ invalidConfigError: () => invalidConfigError,
76
+ invalidPropertyTypeError: () => invalidPropertyTypeError,
77
+ isCompoundType: () => isCompoundType,
78
+ jsonSyntaxError: () => jsonSyntaxError,
79
+ loadSchema: () => loadSchema,
80
+ loadSchemas: () => loadSchemas,
81
+ missingConfigFieldError: () => missingConfigFieldError,
82
+ missingFieldError: () => missingFieldError,
83
+ notImplementedError: () => notImplementedError,
84
+ ok: () => import_omnify_types.ok,
85
+ outputWriteError: () => outputWriteError,
86
+ parseJsonSchema: () => parseJsonSchema,
87
+ parseYamlSchema: () => parseYamlSchema,
88
+ pluginError: () => pluginError,
89
+ pluginNotFoundError: () => pluginNotFoundError,
90
+ pluginTypeConflictError: () => pluginTypeConflictError,
91
+ schemaNotFoundError: () => schemaNotFoundError,
92
+ schemaParseError: () => schemaParseError,
93
+ validateAssociations: () => validateAssociations,
94
+ validateEnumSchema: () => validateEnumSchema,
95
+ validateOptions: () => validateOptions,
96
+ validateProperties: () => validateProperties,
97
+ validatePropertyType: () => validatePropertyType,
98
+ validateSchema: () => validateSchema,
99
+ validateSchemas: () => validateSchemas,
100
+ validationError: () => validationError,
101
+ yamlSyntaxError: () => yamlSyntaxError
102
+ });
103
+ module.exports = __toCommonJS(index_exports);
104
+ var import_omnify_types = require("@famgia/omnify-types");
105
+
106
+ // src/errors/omnify-error.ts
107
+ var OmnifyError = class _OmnifyError extends Error {
108
+ /** Error code (e.g., 'E201') */
109
+ code;
110
+ /** Source location where the error occurred */
111
+ location;
112
+ /** Suggested fix for the error */
113
+ suggestion;
114
+ /** Additional context or details */
115
+ details;
116
+ /** Original error if this wraps another error */
117
+ cause;
118
+ constructor(message, code, location, suggestion, options) {
119
+ super(message);
120
+ this.name = "OmnifyError";
121
+ this.code = code;
122
+ if (location !== void 0) {
123
+ this.location = location;
124
+ }
125
+ if (suggestion !== void 0) {
126
+ this.suggestion = suggestion;
127
+ }
128
+ if (options?.details !== void 0) {
129
+ this.details = options.details;
130
+ }
131
+ if (options?.cause !== void 0) {
132
+ this.cause = options.cause;
133
+ }
134
+ if (Error.captureStackTrace) {
135
+ Error.captureStackTrace(this, _OmnifyError);
136
+ }
137
+ }
138
+ /**
139
+ * Creates an OmnifyError from an OmnifyErrorInfo object.
140
+ */
141
+ static fromInfo(info) {
142
+ const options = {};
143
+ if (info.details !== void 0) {
144
+ options.details = info.details;
145
+ }
146
+ if (info.cause !== void 0) {
147
+ options.cause = info.cause;
148
+ }
149
+ return new _OmnifyError(
150
+ info.message,
151
+ info.code,
152
+ info.location,
153
+ info.suggestion,
154
+ Object.keys(options).length > 0 ? options : void 0
155
+ );
156
+ }
157
+ /**
158
+ * Wraps an unknown error as an OmnifyError.
159
+ * Useful for catching and re-throwing with context.
160
+ */
161
+ static wrap(error, code = "E901", location) {
162
+ if (error instanceof _OmnifyError) {
163
+ return error;
164
+ }
165
+ const message = error instanceof Error ? error.message : String(error);
166
+ if (error instanceof Error) {
167
+ return new _OmnifyError(message, code, location, void 0, { cause: error });
168
+ }
169
+ return new _OmnifyError(message, code, location);
170
+ }
171
+ /**
172
+ * Converts to OmnifyErrorInfo for serialization.
173
+ */
174
+ toInfo() {
175
+ const info = {
176
+ code: this.code,
177
+ message: this.message
178
+ };
179
+ if (this.location !== void 0) {
180
+ info.location = this.location;
181
+ }
182
+ if (this.suggestion !== void 0) {
183
+ info.suggestion = this.suggestion;
184
+ }
185
+ if (this.details !== void 0) {
186
+ info.details = this.details;
187
+ }
188
+ if (this.cause !== void 0) {
189
+ info.cause = this.cause;
190
+ }
191
+ return info;
192
+ }
193
+ /**
194
+ * Returns a formatted string representation.
195
+ * Format: "Error [CODE]: message\n --> file:line:column"
196
+ */
197
+ toString() {
198
+ const parts = [];
199
+ parts.push(`Error [${this.code}]: ${this.message}`);
200
+ if (this.location?.file) {
201
+ const loc = this.location;
202
+ let locationStr = ` --> ${loc.file}`;
203
+ if (loc.line !== void 0) {
204
+ locationStr += `:${loc.line}`;
205
+ if (loc.column !== void 0) {
206
+ locationStr += `:${loc.column}`;
207
+ }
208
+ }
209
+ parts.push(locationStr);
210
+ }
211
+ if (this.suggestion) {
212
+ parts.push(` Suggestion: ${this.suggestion}`);
213
+ }
214
+ return parts.join("\n");
215
+ }
216
+ /**
217
+ * Returns the file path from location, if available.
218
+ */
219
+ get file() {
220
+ return this.location?.file;
221
+ }
222
+ /**
223
+ * Returns the line number from location, if available.
224
+ */
225
+ get line() {
226
+ return this.location?.line;
227
+ }
228
+ /**
229
+ * Returns the column number from location, if available.
230
+ */
231
+ get column() {
232
+ return this.location?.column;
233
+ }
234
+ };
235
+
236
+ // src/errors/formatter.ts
237
+ var colors = {
238
+ reset: "\x1B[0m",
239
+ bold: "\x1B[1m",
240
+ dim: "\x1B[2m",
241
+ red: "\x1B[31m",
242
+ yellow: "\x1B[33m",
243
+ blue: "\x1B[34m",
244
+ cyan: "\x1B[36m",
245
+ gray: "\x1B[90m"
246
+ };
247
+ function colorize(text, colorCode, enabled) {
248
+ return enabled ? `${colorCode}${text}${colors.reset}` : text;
249
+ }
250
+ function formatError(error, options = {}) {
251
+ const {
252
+ color = true,
253
+ showContext = true,
254
+ contextLines = 2,
255
+ sourceContent
256
+ } = options;
257
+ const lines = [];
258
+ const errorLabel = colorize("error", colors.red + colors.bold, color);
259
+ const code = colorize(`[${error.code}]`, colors.red, color);
260
+ const message = colorize(error.message, colors.bold, color);
261
+ lines.push(`${errorLabel}${code}: ${message}`);
262
+ const locFile = error.location?.file;
263
+ if (locFile !== void 0) {
264
+ const loc = error.location;
265
+ let locationStr = colorize(" --> ", colors.blue, color);
266
+ locationStr += colorize(locFile, colors.cyan, color);
267
+ if (loc?.line !== void 0) {
268
+ locationStr += `:${loc.line}`;
269
+ if (loc.column !== void 0) {
270
+ locationStr += `:${loc.column}`;
271
+ }
272
+ }
273
+ lines.push(locationStr);
274
+ }
275
+ if (showContext && sourceContent && error.location?.line !== void 0) {
276
+ const contextOutput = formatSourceContext(
277
+ sourceContent,
278
+ error.location.line,
279
+ error.location.column,
280
+ error.suggestion,
281
+ contextLines,
282
+ color
283
+ );
284
+ lines.push(contextOutput);
285
+ }
286
+ if (error.suggestion && (!showContext || !sourceContent)) {
287
+ const suggestionLabel = colorize(" = suggestion:", colors.cyan, color);
288
+ lines.push(`${suggestionLabel} ${error.suggestion}`);
289
+ }
290
+ return lines.join("\n");
291
+ }
292
+ function formatSourceContext(source, errorLine, errorColumn, suggestion, contextCount, colorEnabled) {
293
+ const sourceLines = source.split("\n");
294
+ const startLine = Math.max(1, errorLine - contextCount);
295
+ const endLine = Math.min(sourceLines.length, errorLine + contextCount);
296
+ const gutterWidth = String(endLine).length;
297
+ const output = [];
298
+ output.push(colorize(`${" ".repeat(gutterWidth)} |`, colors.blue, colorEnabled));
299
+ for (let i = startLine; i <= endLine; i++) {
300
+ const lineContent = sourceLines[i - 1] ?? "";
301
+ const lineNum = String(i).padStart(gutterWidth, " ");
302
+ const gutter = colorize(`${lineNum} |`, colors.blue, colorEnabled);
303
+ output.push(`${gutter} ${lineContent}`);
304
+ if (i === errorLine && errorColumn !== void 0) {
305
+ const underlineGutter = colorize(
306
+ `${" ".repeat(gutterWidth)} |`,
307
+ colors.blue,
308
+ colorEnabled
309
+ );
310
+ const spaces = " ".repeat(errorColumn - 1);
311
+ const underline = colorize("^", colors.red, colorEnabled);
312
+ let underlineLine = `${underlineGutter} ${spaces}${underline}`;
313
+ if (suggestion) {
314
+ underlineLine += ` ${colorize(suggestion, colors.yellow, colorEnabled)}`;
315
+ }
316
+ output.push(underlineLine);
317
+ }
318
+ }
319
+ output.push(colorize(`${" ".repeat(gutterWidth)} |`, colors.blue, colorEnabled));
320
+ return output.join("\n");
321
+ }
322
+ function formatErrorSummary(errors, options = {}) {
323
+ const { color = true } = options;
324
+ if (errors.length === 0) {
325
+ return "";
326
+ }
327
+ const formattedErrors = errors.map((e) => formatError(e, options));
328
+ const summary = colorize(
329
+ `
330
+ Found ${errors.length} error${errors.length === 1 ? "" : "s"}`,
331
+ colors.red + colors.bold,
332
+ color
333
+ );
334
+ return formattedErrors.join("\n\n") + summary;
335
+ }
336
+ function formatErrorPlain(error) {
337
+ return formatError(error, { color: false, showContext: false });
338
+ }
339
+ function getExitCode(error) {
340
+ const category = error.code.charAt(1);
341
+ switch (category) {
342
+ case "0":
343
+ return 3;
344
+ case "2":
345
+ return 2;
346
+ default:
347
+ return 1;
348
+ }
349
+ }
350
+
351
+ // src/errors/factories.ts
352
+ function buildLocation(file, line, column) {
353
+ const loc = { file };
354
+ if (line !== void 0) {
355
+ loc.line = line;
356
+ }
357
+ if (column !== void 0) {
358
+ loc.column = column;
359
+ }
360
+ return loc;
361
+ }
362
+ function buildOptions(cause) {
363
+ return cause !== void 0 ? { cause } : void 0;
364
+ }
365
+ function configError(message, code = "E002", suggestion) {
366
+ return new OmnifyError(message, code, void 0, suggestion);
367
+ }
368
+ function configNotFoundError(configPath) {
369
+ return new OmnifyError(
370
+ `Configuration file not found: ${configPath}`,
371
+ "E001",
372
+ { file: configPath },
373
+ "Run `omnify init` to create a configuration file"
374
+ );
375
+ }
376
+ function invalidConfigError(message, configPath) {
377
+ return new OmnifyError(
378
+ message,
379
+ "E002",
380
+ { file: configPath },
381
+ "Check your omnify.config.ts for syntax errors"
382
+ );
383
+ }
384
+ function missingConfigFieldError(field, configPath) {
385
+ return new OmnifyError(
386
+ `Missing required configuration field: ${field}`,
387
+ "E003",
388
+ { file: configPath },
389
+ `Add '${field}' to your configuration file`
390
+ );
391
+ }
392
+ function schemaParseError(message, location, suggestion) {
393
+ return new OmnifyError(message, "E102", location, suggestion);
394
+ }
395
+ function schemaNotFoundError(schemaPath) {
396
+ return new OmnifyError(
397
+ `Schema file not found: ${schemaPath}`,
398
+ "E101",
399
+ { file: schemaPath },
400
+ "Check that the file exists and the path is correct"
401
+ );
402
+ }
403
+ function yamlSyntaxError(message, file, line, column) {
404
+ return new OmnifyError(
405
+ `Invalid YAML syntax: ${message}`,
406
+ "E102",
407
+ buildLocation(file, line, column),
408
+ "Check for proper indentation and YAML syntax"
409
+ );
410
+ }
411
+ function jsonSyntaxError(message, file, line, column) {
412
+ return new OmnifyError(
413
+ `Invalid JSON syntax: ${message}`,
414
+ "E103",
415
+ buildLocation(file, line, column),
416
+ "Check for proper JSON syntax (quotes, commas, brackets)"
417
+ );
418
+ }
419
+ function validationError(message, location, suggestion) {
420
+ return new OmnifyError(message, "E202", location, suggestion);
421
+ }
422
+ function invalidPropertyTypeError(typeName, location, validTypes) {
423
+ const suggestion = validTypes ? `Use one of: ${validTypes.slice(0, 5).join(", ")}${validTypes.length > 5 ? ", ..." : ""}` : void 0;
424
+ return new OmnifyError(
425
+ `Invalid property type '${typeName}'`,
426
+ "E201",
427
+ location,
428
+ suggestion
429
+ );
430
+ }
431
+ function missingFieldError(field, location) {
432
+ return new OmnifyError(
433
+ `Missing required field: ${field}`,
434
+ "E202",
435
+ location,
436
+ `Add '${field}' to the schema definition`
437
+ );
438
+ }
439
+ function invalidAssociationTargetError(target, location, availableSchemas) {
440
+ const suggestion = availableSchemas ? `Available schemas: ${availableSchemas.slice(0, 5).join(", ")}${availableSchemas.length > 5 ? ", ..." : ""}` : "Check that the target schema exists";
441
+ return new OmnifyError(
442
+ `Invalid association target '${target}'`,
443
+ "E203",
444
+ location,
445
+ suggestion
446
+ );
447
+ }
448
+ function circularReferenceError(path2, location) {
449
+ return new OmnifyError(
450
+ `Circular reference detected: ${path2.join(" -> ")}`,
451
+ "E204",
452
+ location,
453
+ "Remove the circular dependency or use a unidirectional relationship"
454
+ );
455
+ }
456
+ function duplicateSchemaError(name, location, existingLocation) {
457
+ const suggestion = existingLocation?.file ? `Schema already defined in ${existingLocation.file}` : "Rename one of the schemas to avoid the conflict";
458
+ return new OmnifyError(
459
+ `Duplicate schema name '${name}'`,
460
+ "E205",
461
+ location,
462
+ suggestion
463
+ );
464
+ }
465
+ function pluginError(message, pluginName, cause) {
466
+ return new OmnifyError(
467
+ message,
468
+ "E302",
469
+ void 0,
470
+ `Check the plugin '${pluginName}' for issues`,
471
+ buildOptions(cause)
472
+ );
473
+ }
474
+ function pluginNotFoundError(pluginName) {
475
+ return new OmnifyError(
476
+ `Plugin not found: ${pluginName}`,
477
+ "E301",
478
+ void 0,
479
+ `Install the plugin with: npm install ${pluginName}`
480
+ );
481
+ }
482
+ function pluginTypeConflictError(typeName, pluginA, pluginB) {
483
+ return new OmnifyError(
484
+ `Type '${typeName}' is defined by multiple plugins: ${pluginA}, ${pluginB}`,
485
+ "E304",
486
+ void 0,
487
+ "Remove one of the conflicting plugins or rename the type"
488
+ );
489
+ }
490
+ function atlasError(message, cause) {
491
+ return new OmnifyError(
492
+ message,
493
+ "E402",
494
+ void 0,
495
+ "Check Atlas CLI output for details",
496
+ buildOptions(cause)
497
+ );
498
+ }
499
+ function atlasNotFoundError() {
500
+ return new OmnifyError(
501
+ "Atlas CLI not found",
502
+ "E401",
503
+ void 0,
504
+ "Install Atlas CLI: https://atlasgo.io/getting-started"
505
+ );
506
+ }
507
+ function generationError(message, outputPath, cause) {
508
+ return new OmnifyError(
509
+ message,
510
+ "E501",
511
+ outputPath ? { file: outputPath } : void 0,
512
+ void 0,
513
+ buildOptions(cause)
514
+ );
515
+ }
516
+ function outputWriteError(outputPath, cause) {
517
+ return new OmnifyError(
518
+ `Failed to write output file: ${outputPath}`,
519
+ "E503",
520
+ { file: outputPath },
521
+ "Check file permissions and disk space",
522
+ buildOptions(cause)
523
+ );
524
+ }
525
+ function internalError(message, cause) {
526
+ return new OmnifyError(
527
+ message,
528
+ "E901",
529
+ void 0,
530
+ "This is a bug. Please report it at https://github.com/omnify/omnify-schema/issues",
531
+ buildOptions(cause)
532
+ );
533
+ }
534
+ function notImplementedError(feature) {
535
+ return new OmnifyError(
536
+ `Feature not implemented: ${feature}`,
537
+ "E902",
538
+ void 0,
539
+ "This feature is planned for a future release"
540
+ );
541
+ }
542
+
543
+ // src/schema/loader.ts
544
+ var fs = __toESM(require("fs/promises"), 1);
545
+ var path = __toESM(require("path"), 1);
546
+ var import_js_yaml = __toESM(require("js-yaml"), 1);
547
+ function fileNameToSchemaName(fileName) {
548
+ const baseName = path.basename(fileName, path.extname(fileName));
549
+ return baseName.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join("");
550
+ }
551
+ function parseYamlSchema(content, filePath) {
552
+ try {
553
+ const parsed = import_js_yaml.default.load(content);
554
+ if (parsed === null || typeof parsed !== "object") {
555
+ throw yamlSyntaxError("Schema must be a YAML object", filePath);
556
+ }
557
+ return buildSchemaDefinition(parsed);
558
+ } catch (error) {
559
+ if (error instanceof import_js_yaml.default.YAMLException) {
560
+ const line = error.mark?.line !== void 0 ? error.mark.line + 1 : void 0;
561
+ const column = error.mark?.column !== void 0 ? error.mark.column + 1 : void 0;
562
+ throw yamlSyntaxError(error.reason || error.message, filePath, line, column);
563
+ }
564
+ throw error;
565
+ }
566
+ }
567
+ function parseJsonSchema(content, filePath) {
568
+ try {
569
+ const parsed = JSON.parse(content);
570
+ if (parsed === null || typeof parsed !== "object") {
571
+ throw jsonSyntaxError("Schema must be a JSON object", filePath);
572
+ }
573
+ return buildSchemaDefinition(parsed);
574
+ } catch (error) {
575
+ if (error instanceof SyntaxError) {
576
+ const match = error.message.match(/position (\d+)/);
577
+ const positionStr = match?.[1];
578
+ const position = positionStr !== void 0 ? parseInt(positionStr, 10) : void 0;
579
+ let line;
580
+ let column;
581
+ if (position !== void 0) {
582
+ const beforeError = content.substring(0, position);
583
+ const lines = beforeError.split("\n");
584
+ line = lines.length;
585
+ const lastLine = lines[lines.length - 1];
586
+ column = (lastLine !== void 0 ? lastLine.length : 0) + 1;
587
+ }
588
+ throw jsonSyntaxError(error.message, filePath, line, column);
589
+ }
590
+ throw error;
591
+ }
592
+ }
593
+ function buildSchemaDefinition(data) {
594
+ const schema = {};
595
+ if (data.kind !== void 0) {
596
+ schema.kind = data.kind;
597
+ }
598
+ if (data.displayName !== void 0 && typeof data.displayName === "string") {
599
+ schema.displayName = data.displayName;
600
+ }
601
+ if (data.titleIndex !== void 0 && typeof data.titleIndex === "string") {
602
+ schema.titleIndex = data.titleIndex;
603
+ }
604
+ if (data.group !== void 0 && typeof data.group === "string") {
605
+ schema.group = data.group;
606
+ }
607
+ if (data.options !== void 0 && typeof data.options === "object") {
608
+ const options = buildSchemaOptions(data.options);
609
+ if (Object.keys(options).length > 0) {
610
+ schema.options = options;
611
+ }
612
+ }
613
+ if (data.properties !== void 0 && typeof data.properties === "object") {
614
+ const properties = buildProperties(data.properties);
615
+ if (Object.keys(properties).length > 0) {
616
+ schema.properties = properties;
617
+ }
618
+ }
619
+ if (data.values !== void 0 && Array.isArray(data.values)) {
620
+ schema.values = data.values;
621
+ }
622
+ return schema;
623
+ }
624
+ function buildSchemaOptions(data) {
625
+ const options = {};
626
+ if (data.timestamps !== void 0 && typeof data.timestamps === "boolean") {
627
+ options.timestamps = data.timestamps;
628
+ }
629
+ if (data.softDelete !== void 0 && typeof data.softDelete === "boolean") {
630
+ options.softDelete = data.softDelete;
631
+ }
632
+ if (data.unique !== void 0) {
633
+ options.unique = data.unique;
634
+ }
635
+ if (data.indexes !== void 0 && Array.isArray(data.indexes)) {
636
+ options.indexes = data.indexes;
637
+ }
638
+ if (data.translations !== void 0 && typeof data.translations === "boolean") {
639
+ options.translations = data.translations;
640
+ }
641
+ if (data.tableName !== void 0 && typeof data.tableName === "string") {
642
+ options.tableName = data.tableName;
643
+ }
644
+ if (data.primaryKeyType !== void 0) {
645
+ options.primaryKeyType = data.primaryKeyType;
646
+ }
647
+ if (data.authenticatable !== void 0 && typeof data.authenticatable === "boolean") {
648
+ options.authenticatable = data.authenticatable;
649
+ }
650
+ if (data.authenticatableLoginIdField !== void 0 && typeof data.authenticatableLoginIdField === "string") {
651
+ options.authenticatableLoginIdField = data.authenticatableLoginIdField;
652
+ }
653
+ if (data.authenticatablePasswordField !== void 0 && typeof data.authenticatablePasswordField === "string") {
654
+ options.authenticatablePasswordField = data.authenticatablePasswordField;
655
+ }
656
+ if (data.authenticatableGuardName !== void 0 && typeof data.authenticatableGuardName === "string") {
657
+ options.authenticatableGuardName = data.authenticatableGuardName;
658
+ }
659
+ return options;
660
+ }
661
+ function buildProperties(data) {
662
+ const properties = {};
663
+ for (const [name, value] of Object.entries(data)) {
664
+ if (value !== void 0 && typeof value === "object" && value !== null) {
665
+ properties[name] = buildPropertyDefinition(value);
666
+ }
667
+ }
668
+ return properties;
669
+ }
670
+ function buildPropertyDefinition(data) {
671
+ const prop = {
672
+ type: data.type || "String"
673
+ };
674
+ if (data.displayName !== void 0 && typeof data.displayName === "string") {
675
+ prop.displayName = data.displayName;
676
+ }
677
+ if (data.nullable !== void 0 && typeof data.nullable === "boolean") {
678
+ prop.nullable = data.nullable;
679
+ }
680
+ if (data.default !== void 0) {
681
+ prop.default = data.default;
682
+ }
683
+ if (data.unique !== void 0 && typeof data.unique === "boolean") {
684
+ prop.unique = data.unique;
685
+ }
686
+ if (data.description !== void 0 && typeof data.description === "string") {
687
+ prop.description = data.description;
688
+ }
689
+ if (data.length !== void 0 && typeof data.length === "number") {
690
+ prop.length = data.length;
691
+ }
692
+ if (data.unsigned !== void 0 && typeof data.unsigned === "boolean") {
693
+ prop.unsigned = data.unsigned;
694
+ }
695
+ if (data.precision !== void 0 && typeof data.precision === "number") {
696
+ prop.precision = data.precision;
697
+ }
698
+ if (data.scale !== void 0 && typeof data.scale === "number") {
699
+ prop.scale = data.scale;
700
+ }
701
+ if (data.enum !== void 0) {
702
+ prop.enum = data.enum;
703
+ }
704
+ if (data.options !== void 0 && Array.isArray(data.options)) {
705
+ prop.options = data.options;
706
+ }
707
+ if (data.source !== void 0 && typeof data.source === "string") {
708
+ prop.source = data.source;
709
+ }
710
+ if (data.relation !== void 0 && typeof data.relation === "string") {
711
+ prop.relation = data.relation;
712
+ }
713
+ if (data.target !== void 0 && typeof data.target === "string") {
714
+ prop.target = data.target;
715
+ }
716
+ if (data.inversedBy !== void 0 && typeof data.inversedBy === "string") {
717
+ prop.inversedBy = data.inversedBy;
718
+ }
719
+ if (data.mappedBy !== void 0 && typeof data.mappedBy === "string") {
720
+ prop.mappedBy = data.mappedBy;
721
+ }
722
+ if (data.onDelete !== void 0 && typeof data.onDelete === "string") {
723
+ prop.onDelete = data.onDelete;
724
+ }
725
+ if (data.onUpdate !== void 0 && typeof data.onUpdate === "string") {
726
+ prop.onUpdate = data.onUpdate;
727
+ }
728
+ if (data.owning !== void 0 && typeof data.owning === "boolean") {
729
+ prop.owning = data.owning;
730
+ }
731
+ if (data.joinTable !== void 0 && typeof data.joinTable === "string") {
732
+ prop.joinTable = data.joinTable;
733
+ }
734
+ return prop;
735
+ }
736
+ async function loadSchema(filePath, options = {}) {
737
+ const absolutePath = path.resolve(filePath);
738
+ const baseDir = options.baseDir ? path.resolve(options.baseDir) : path.dirname(absolutePath);
739
+ try {
740
+ await fs.access(absolutePath);
741
+ } catch {
742
+ throw schemaNotFoundError(filePath);
743
+ }
744
+ const content = await fs.readFile(absolutePath, "utf-8");
745
+ const ext = path.extname(absolutePath).toLowerCase();
746
+ const schemaDefinition = ext === ".json" ? parseJsonSchema(content, filePath) : parseYamlSchema(content, filePath);
747
+ const name = fileNameToSchemaName(absolutePath);
748
+ const relativePath = path.relative(baseDir, absolutePath);
749
+ const loadedSchema = {
750
+ ...schemaDefinition,
751
+ name,
752
+ filePath: absolutePath,
753
+ relativePath
754
+ };
755
+ return loadedSchema;
756
+ }
757
+ async function findSchemaFiles(dirPath, extensions, recursive) {
758
+ const files = [];
759
+ const entries = await fs.readdir(dirPath, { withFileTypes: true });
760
+ for (const entry of entries) {
761
+ const fullPath = path.join(dirPath, entry.name);
762
+ if (entry.isDirectory() && recursive) {
763
+ const subFiles = await findSchemaFiles(fullPath, extensions, recursive);
764
+ files.push(...subFiles);
765
+ } else if (entry.isFile()) {
766
+ const ext = path.extname(entry.name).toLowerCase();
767
+ if (extensions.includes(ext)) {
768
+ files.push(fullPath);
769
+ }
770
+ }
771
+ }
772
+ return files;
773
+ }
774
+ async function loadSchemas(directoryPath, options = {}) {
775
+ const {
776
+ extensions = [".yaml", ".yml", ".json"],
777
+ recursive = true
778
+ } = options;
779
+ const absoluteDir = path.resolve(directoryPath);
780
+ try {
781
+ const stat2 = await fs.stat(absoluteDir);
782
+ if (!stat2.isDirectory()) {
783
+ throw schemaNotFoundError(directoryPath);
784
+ }
785
+ } catch (error) {
786
+ if (error.code === "ENOENT") {
787
+ throw schemaNotFoundError(directoryPath);
788
+ }
789
+ throw error;
790
+ }
791
+ const schemaFiles = await findSchemaFiles(absoluteDir, extensions, recursive);
792
+ const schemas = {};
793
+ const schemaLocations = {};
794
+ for (const filePath of schemaFiles) {
795
+ const schema = await loadSchema(filePath, { baseDir: absoluteDir });
796
+ const existingLocation = schemaLocations[schema.name];
797
+ if (existingLocation !== void 0) {
798
+ throw duplicateSchemaError(
799
+ schema.name,
800
+ { file: filePath },
801
+ { file: existingLocation }
802
+ );
803
+ }
804
+ schemas[schema.name] = schema;
805
+ schemaLocations[schema.name] = filePath;
806
+ }
807
+ return schemas;
808
+ }
809
+
810
+ // src/validation/validator.ts
811
+ var BUILT_IN_TYPES = [
812
+ "String",
813
+ "Int",
814
+ "BigInt",
815
+ "Float",
816
+ "Boolean",
817
+ "Text",
818
+ "LongText",
819
+ "Date",
820
+ "Time",
821
+ "Timestamp",
822
+ "Json",
823
+ "Email",
824
+ "Password",
825
+ "File",
826
+ "MultiFile",
827
+ "Enum",
828
+ "Select",
829
+ "Lookup",
830
+ "Association",
831
+ "Polymorphic"
832
+ ];
833
+ var VALID_RELATIONS = [
834
+ "OneToOne",
835
+ "OneToMany",
836
+ "ManyToOne",
837
+ "ManyToMany"
838
+ ];
839
+ var VALID_REFERENTIAL_ACTIONS = [
840
+ "CASCADE",
841
+ "SET NULL",
842
+ "SET DEFAULT",
843
+ "RESTRICT",
844
+ "NO ACTION"
845
+ ];
846
+ var VALID_PRIMARY_KEY_TYPES = ["Int", "BigInt", "Uuid", "String"];
847
+ function buildLocation2(file, line, column) {
848
+ const loc = { file };
849
+ if (line !== void 0) {
850
+ loc.line = line;
851
+ }
852
+ if (column !== void 0) {
853
+ loc.column = column;
854
+ }
855
+ return loc;
856
+ }
857
+ function validatePropertyType(propertyName, property, filePath, customTypes = []) {
858
+ const errors = [];
859
+ const validTypes = [...BUILT_IN_TYPES, ...customTypes];
860
+ if (!property.type) {
861
+ errors.push(
862
+ missingFieldError("type", buildLocation2(filePath))
863
+ );
864
+ return errors;
865
+ }
866
+ if (!validTypes.includes(property.type)) {
867
+ errors.push(
868
+ invalidPropertyTypeError(
869
+ property.type,
870
+ buildLocation2(filePath),
871
+ BUILT_IN_TYPES
872
+ )
873
+ );
874
+ }
875
+ if (property.type === "Enum") {
876
+ const enumProp = property;
877
+ if (enumProp.enum === void 0) {
878
+ errors.push(
879
+ validationError(
880
+ `Property '${propertyName}' of type 'Enum' requires 'enum' field`,
881
+ buildLocation2(filePath),
882
+ "Add enum values: enum: [value1, value2]"
883
+ )
884
+ );
885
+ }
886
+ }
887
+ if (property.type === "Association") {
888
+ const assocProp = property;
889
+ if (assocProp.relation === void 0) {
890
+ errors.push(
891
+ validationError(
892
+ `Property '${propertyName}' of type 'Association' requires 'relation' field`,
893
+ buildLocation2(filePath),
894
+ "Add relation: OneToOne, OneToMany, ManyToOne, or ManyToMany"
895
+ )
896
+ );
897
+ }
898
+ if (assocProp.target === void 0) {
899
+ errors.push(
900
+ validationError(
901
+ `Property '${propertyName}' of type 'Association' requires 'target' field`,
902
+ buildLocation2(filePath),
903
+ "Add target schema name: target: User"
904
+ )
905
+ );
906
+ }
907
+ }
908
+ return errors;
909
+ }
910
+ function validateProperties(schema, filePath, customTypes = []) {
911
+ const errors = [];
912
+ if (!schema.properties) {
913
+ if (schema.kind !== "enum") {
914
+ }
915
+ return errors;
916
+ }
917
+ for (const [name, property] of Object.entries(schema.properties)) {
918
+ const propErrors = validatePropertyType(name, property, filePath, customTypes);
919
+ errors.push(...propErrors);
920
+ }
921
+ return errors;
922
+ }
923
+ function validateAssociations(schema, allSchemas) {
924
+ const errors = [];
925
+ if (!schema.properties) {
926
+ return errors;
927
+ }
928
+ const availableSchemas = Object.keys(allSchemas);
929
+ for (const [name, property] of Object.entries(schema.properties)) {
930
+ if (property.type !== "Association") {
931
+ continue;
932
+ }
933
+ const assocProp = property;
934
+ if (assocProp.relation && !VALID_RELATIONS.includes(assocProp.relation)) {
935
+ errors.push(
936
+ validationError(
937
+ `Property '${name}' has invalid relation '${assocProp.relation}'`,
938
+ buildLocation2(schema.filePath),
939
+ `Use one of: ${VALID_RELATIONS.join(", ")}`
940
+ )
941
+ );
942
+ }
943
+ if (assocProp.target && !availableSchemas.includes(assocProp.target)) {
944
+ errors.push(
945
+ invalidAssociationTargetError(
946
+ assocProp.target,
947
+ buildLocation2(schema.filePath),
948
+ availableSchemas
949
+ )
950
+ );
951
+ }
952
+ if (assocProp.inversedBy && assocProp.target) {
953
+ const targetSchema = allSchemas[assocProp.target];
954
+ if (targetSchema?.properties) {
955
+ const inverseProperty = targetSchema.properties[assocProp.inversedBy];
956
+ if (!inverseProperty) {
957
+ errors.push(
958
+ validationError(
959
+ `Property '${name}' references non-existent inverse property '${assocProp.inversedBy}' on '${assocProp.target}'`,
960
+ buildLocation2(schema.filePath),
961
+ `Add property '${assocProp.inversedBy}' to ${assocProp.target} schema`
962
+ )
963
+ );
964
+ }
965
+ }
966
+ }
967
+ if (assocProp.onDelete && !VALID_REFERENTIAL_ACTIONS.includes(assocProp.onDelete)) {
968
+ errors.push(
969
+ validationError(
970
+ `Property '${name}' has invalid onDelete action '${assocProp.onDelete}'`,
971
+ buildLocation2(schema.filePath),
972
+ `Use one of: ${VALID_REFERENTIAL_ACTIONS.join(", ")}`
973
+ )
974
+ );
975
+ }
976
+ if (assocProp.onUpdate && !VALID_REFERENTIAL_ACTIONS.includes(assocProp.onUpdate)) {
977
+ errors.push(
978
+ validationError(
979
+ `Property '${name}' has invalid onUpdate action '${assocProp.onUpdate}'`,
980
+ buildLocation2(schema.filePath),
981
+ `Use one of: ${VALID_REFERENTIAL_ACTIONS.join(", ")}`
982
+ )
983
+ );
984
+ }
985
+ }
986
+ return errors;
987
+ }
988
+ function validateOptions(schema, filePath) {
989
+ const errors = [];
990
+ const options = schema.options;
991
+ if (!options) {
992
+ return errors;
993
+ }
994
+ if (options.primaryKeyType !== void 0) {
995
+ if (!VALID_PRIMARY_KEY_TYPES.includes(options.primaryKeyType)) {
996
+ errors.push(
997
+ validationError(
998
+ `Invalid primaryKeyType '${options.primaryKeyType}'`,
999
+ buildLocation2(filePath),
1000
+ `Use one of: ${VALID_PRIMARY_KEY_TYPES.join(", ")}`
1001
+ )
1002
+ );
1003
+ }
1004
+ }
1005
+ if (options.unique && schema.properties) {
1006
+ const propertyNames = Object.keys(schema.properties);
1007
+ const uniqueConstraints = Array.isArray(options.unique[0]) ? options.unique : [options.unique];
1008
+ for (const constraint of uniqueConstraints) {
1009
+ for (const column of constraint) {
1010
+ if (!propertyNames.includes(column)) {
1011
+ errors.push(
1012
+ validationError(
1013
+ `Unique constraint references non-existent property '${column}'`,
1014
+ buildLocation2(filePath),
1015
+ `Available properties: ${propertyNames.join(", ")}`
1016
+ )
1017
+ );
1018
+ }
1019
+ }
1020
+ }
1021
+ }
1022
+ if (options.indexes && schema.properties) {
1023
+ const propertyNames = Object.keys(schema.properties);
1024
+ for (const index of options.indexes) {
1025
+ for (const column of index.columns) {
1026
+ if (!propertyNames.includes(column)) {
1027
+ errors.push(
1028
+ validationError(
1029
+ `Index references non-existent property '${column}'`,
1030
+ buildLocation2(filePath),
1031
+ `Available properties: ${propertyNames.join(", ")}`
1032
+ )
1033
+ );
1034
+ }
1035
+ }
1036
+ }
1037
+ }
1038
+ if (options.authenticatable) {
1039
+ if (options.authenticatableLoginIdField && schema.properties) {
1040
+ if (!schema.properties[options.authenticatableLoginIdField]) {
1041
+ errors.push(
1042
+ validationError(
1043
+ `authenticatableLoginIdField references non-existent property '${options.authenticatableLoginIdField}'`,
1044
+ buildLocation2(filePath)
1045
+ )
1046
+ );
1047
+ }
1048
+ }
1049
+ if (options.authenticatablePasswordField && schema.properties) {
1050
+ if (!schema.properties[options.authenticatablePasswordField]) {
1051
+ errors.push(
1052
+ validationError(
1053
+ `authenticatablePasswordField references non-existent property '${options.authenticatablePasswordField}'`,
1054
+ buildLocation2(filePath)
1055
+ )
1056
+ );
1057
+ }
1058
+ }
1059
+ }
1060
+ return errors;
1061
+ }
1062
+ function validateEnumSchema(schema, filePath) {
1063
+ const errors = [];
1064
+ if (schema.kind !== "enum") {
1065
+ return errors;
1066
+ }
1067
+ if (!schema.values || schema.values.length === 0) {
1068
+ errors.push(
1069
+ validationError(
1070
+ "Enum schema requires at least one value",
1071
+ buildLocation2(filePath),
1072
+ "Add values: [value1, value2, ...]"
1073
+ )
1074
+ );
1075
+ }
1076
+ if (schema.values) {
1077
+ const seen = /* @__PURE__ */ new Set();
1078
+ for (const value of schema.values) {
1079
+ if (seen.has(value)) {
1080
+ errors.push(
1081
+ validationError(
1082
+ `Duplicate enum value '${value}'`,
1083
+ buildLocation2(filePath)
1084
+ )
1085
+ );
1086
+ }
1087
+ seen.add(value);
1088
+ }
1089
+ }
1090
+ return errors;
1091
+ }
1092
+ function validateSchema(schema, options = {}) {
1093
+ const errors = [];
1094
+ const warnings = [];
1095
+ const customTypes = options.customTypes ?? [];
1096
+ const propErrors = validateProperties(schema, schema.filePath, customTypes);
1097
+ errors.push(...propErrors);
1098
+ const optErrors = validateOptions(schema, schema.filePath);
1099
+ errors.push(...optErrors);
1100
+ if (schema.kind === "enum") {
1101
+ const enumErrors = validateEnumSchema(schema, schema.filePath);
1102
+ errors.push(...enumErrors);
1103
+ }
1104
+ if (schema.titleIndex && schema.properties) {
1105
+ if (!schema.properties[schema.titleIndex]) {
1106
+ errors.push(
1107
+ validationError(
1108
+ `titleIndex references non-existent property '${schema.titleIndex}'`,
1109
+ buildLocation2(schema.filePath),
1110
+ `Available properties: ${Object.keys(schema.properties).join(", ")}`
1111
+ )
1112
+ );
1113
+ }
1114
+ }
1115
+ return {
1116
+ schemaName: schema.name,
1117
+ valid: errors.length === 0,
1118
+ errors,
1119
+ warnings
1120
+ };
1121
+ }
1122
+ function validateSchemas(schemas, options = {}) {
1123
+ const schemaResults = [];
1124
+ const allErrors = [];
1125
+ const allWarnings = [];
1126
+ const validateAssocs = options.validateAssociations ?? true;
1127
+ for (const schema of Object.values(schemas)) {
1128
+ const result = validateSchema(schema, options);
1129
+ schemaResults.push(result);
1130
+ allErrors.push(...result.errors);
1131
+ allWarnings.push(...result.warnings);
1132
+ }
1133
+ if (validateAssocs) {
1134
+ for (const schema of Object.values(schemas)) {
1135
+ const assocErrors = validateAssociations(schema, schemas);
1136
+ allErrors.push(...assocErrors);
1137
+ const existingResult = schemaResults.find((r) => r.schemaName === schema.name);
1138
+ if (existingResult && assocErrors.length > 0) {
1139
+ const updatedResult = {
1140
+ ...existingResult,
1141
+ valid: false,
1142
+ errors: [...existingResult.errors, ...assocErrors]
1143
+ };
1144
+ const index = schemaResults.indexOf(existingResult);
1145
+ schemaResults[index] = updatedResult;
1146
+ }
1147
+ }
1148
+ }
1149
+ return {
1150
+ valid: allErrors.length === 0,
1151
+ errorCount: allErrors.length,
1152
+ warningCount: allWarnings.length,
1153
+ schemas: schemaResults,
1154
+ errors: allErrors,
1155
+ warnings: allWarnings
1156
+ };
1157
+ }
1158
+
1159
+ // src/plugins/manager.ts
1160
+ var nullLogger = {
1161
+ debug: () => {
1162
+ },
1163
+ info: () => {
1164
+ },
1165
+ warn: () => {
1166
+ },
1167
+ error: () => {
1168
+ }
1169
+ };
1170
+ var consoleLogger = {
1171
+ debug: (msg) => console.log(`[plugin:debug] ${msg}`),
1172
+ info: (msg) => console.log(`[plugin:info] ${msg}`),
1173
+ warn: (msg) => console.warn(`[plugin:warn] ${msg}`),
1174
+ error: (msg) => console.error(`[plugin:error] ${msg}`)
1175
+ };
1176
+ var PluginManager = class {
1177
+ _plugins = /* @__PURE__ */ new Map();
1178
+ _types = /* @__PURE__ */ new Map();
1179
+ _cwd;
1180
+ _verbose;
1181
+ _logger;
1182
+ constructor(options = {}) {
1183
+ this._cwd = options.cwd ?? process.cwd();
1184
+ this._verbose = options.verbose ?? false;
1185
+ this._logger = options.logger ?? (this._verbose ? consoleLogger : nullLogger);
1186
+ }
1187
+ /**
1188
+ * Creates a plugin context for plugin setup.
1189
+ */
1190
+ createContext() {
1191
+ return {
1192
+ cwd: this._cwd,
1193
+ verbose: this._verbose,
1194
+ logger: this._logger
1195
+ };
1196
+ }
1197
+ /**
1198
+ * Registers a single plugin.
1199
+ */
1200
+ async register(plugin) {
1201
+ const warnings = [];
1202
+ const registeredTypes = [];
1203
+ if (this._plugins.has(plugin.name)) {
1204
+ return {
1205
+ success: false,
1206
+ types: [],
1207
+ warnings: [],
1208
+ error: `Plugin '${plugin.name}' is already registered`
1209
+ };
1210
+ }
1211
+ this._logger.debug(`Registering plugin: ${plugin.name}@${plugin.version}`);
1212
+ if (plugin.setup) {
1213
+ try {
1214
+ await plugin.setup(this.createContext());
1215
+ } catch (error) {
1216
+ const message = error instanceof Error ? error.message : String(error);
1217
+ return {
1218
+ success: false,
1219
+ types: [],
1220
+ warnings: [],
1221
+ error: `Plugin setup failed: ${message}`
1222
+ };
1223
+ }
1224
+ }
1225
+ if (plugin.types) {
1226
+ for (const typeDef of plugin.types) {
1227
+ const existing = this._types.get(typeDef.name);
1228
+ if (existing) {
1229
+ throw pluginTypeConflictError(
1230
+ typeDef.name,
1231
+ existing.pluginName,
1232
+ plugin.name
1233
+ );
1234
+ }
1235
+ const validationError2 = this.validateTypeDefinition(typeDef);
1236
+ if (validationError2) {
1237
+ warnings.push(`Type '${typeDef.name}': ${validationError2}`);
1238
+ continue;
1239
+ }
1240
+ const registeredType = {
1241
+ ...typeDef,
1242
+ pluginName: plugin.name,
1243
+ pluginVersion: plugin.version
1244
+ };
1245
+ this._types.set(typeDef.name, registeredType);
1246
+ registeredTypes.push(registeredType);
1247
+ this._logger.debug(` Registered type: ${typeDef.name}`);
1248
+ }
1249
+ }
1250
+ this._plugins.set(plugin.name, plugin);
1251
+ this._logger.info(`Plugin registered: ${plugin.name} (${registeredTypes.length} types)`);
1252
+ return {
1253
+ success: true,
1254
+ types: registeredTypes,
1255
+ warnings
1256
+ };
1257
+ }
1258
+ /**
1259
+ * Registers multiple plugins.
1260
+ */
1261
+ async registerAll(plugins) {
1262
+ for (const plugin of plugins) {
1263
+ const result = await this.register(plugin);
1264
+ if (!result.success) {
1265
+ throw pluginError(result.error ?? "Unknown error", plugin.name);
1266
+ }
1267
+ }
1268
+ }
1269
+ /**
1270
+ * Validates a type definition.
1271
+ */
1272
+ validateTypeDefinition(typeDef) {
1273
+ if (!typeDef.name || typeDef.name.length === 0) {
1274
+ return "Type name is required";
1275
+ }
1276
+ if (typeDef.compound) {
1277
+ if (!typeDef.expand || typeDef.expand.length === 0) {
1278
+ return "Compound type must have expand definitions";
1279
+ }
1280
+ for (const field of typeDef.expand) {
1281
+ if (!field.suffix) {
1282
+ return "Expanded field must have a suffix";
1283
+ }
1284
+ if (!field.sql || !field.sql.sqlType) {
1285
+ return `Expanded field '${field.suffix}' must have SQL type`;
1286
+ }
1287
+ if (!field.typescript || !field.typescript.type) {
1288
+ return `Expanded field '${field.suffix}' must have TypeScript type`;
1289
+ }
1290
+ }
1291
+ } else {
1292
+ if (!typeDef.sql || !typeDef.sql.sqlType) {
1293
+ return "Non-compound type must have SQL definition";
1294
+ }
1295
+ if (!typeDef.typescript || !typeDef.typescript.type) {
1296
+ return "Non-compound type must have TypeScript type";
1297
+ }
1298
+ }
1299
+ return void 0;
1300
+ }
1301
+ /**
1302
+ * Unregisters a plugin and its types.
1303
+ */
1304
+ async unregister(pluginName) {
1305
+ const plugin = this._plugins.get(pluginName);
1306
+ if (!plugin) {
1307
+ throw pluginNotFoundError(pluginName);
1308
+ }
1309
+ if (plugin.teardown) {
1310
+ try {
1311
+ await plugin.teardown();
1312
+ } catch (error) {
1313
+ const message = error instanceof Error ? error.message : String(error);
1314
+ this._logger.warn(`Plugin teardown failed: ${message}`);
1315
+ }
1316
+ }
1317
+ for (const [typeName, type] of this._types) {
1318
+ if (type.pluginName === pluginName) {
1319
+ this._types.delete(typeName);
1320
+ }
1321
+ }
1322
+ this._plugins.delete(pluginName);
1323
+ this._logger.info(`Plugin unregistered: ${pluginName}`);
1324
+ }
1325
+ /**
1326
+ * Gets a registered type by name.
1327
+ */
1328
+ getType(typeName) {
1329
+ return this._types.get(typeName);
1330
+ }
1331
+ /**
1332
+ * Checks if a type is registered.
1333
+ */
1334
+ hasType(typeName) {
1335
+ return this._types.has(typeName);
1336
+ }
1337
+ /**
1338
+ * Gets all registered types.
1339
+ */
1340
+ getAllTypes() {
1341
+ return this._types;
1342
+ }
1343
+ /**
1344
+ * Gets all registered type names.
1345
+ */
1346
+ getTypeNames() {
1347
+ return Array.from(this._types.keys());
1348
+ }
1349
+ /**
1350
+ * Gets a registered plugin by name.
1351
+ */
1352
+ getPlugin(pluginName) {
1353
+ return this._plugins.get(pluginName);
1354
+ }
1355
+ /**
1356
+ * Gets all registered plugins.
1357
+ */
1358
+ getAllPlugins() {
1359
+ return this._plugins;
1360
+ }
1361
+ /**
1362
+ * Gets the current registry state.
1363
+ */
1364
+ getRegistry() {
1365
+ return {
1366
+ plugins: this._plugins,
1367
+ types: this._types
1368
+ };
1369
+ }
1370
+ /**
1371
+ * Clears all registered plugins and types.
1372
+ */
1373
+ async clear() {
1374
+ for (const plugin of this._plugins.values()) {
1375
+ if (plugin.teardown) {
1376
+ try {
1377
+ await plugin.teardown();
1378
+ } catch {
1379
+ }
1380
+ }
1381
+ }
1382
+ this._plugins.clear();
1383
+ this._types.clear();
1384
+ this._logger.debug("Plugin registry cleared");
1385
+ }
1386
+ };
1387
+ function createPluginManager(options) {
1388
+ return new PluginManager(options);
1389
+ }
1390
+
1391
+ // src/plugins/expander.ts
1392
+ function expandProperty(propertyName, property, registry) {
1393
+ const typeName = property.type;
1394
+ const registeredType = registry.types.get(typeName);
1395
+ if (!registeredType || !registeredType.compound || !registeredType.expand) {
1396
+ return [{
1397
+ originalName: propertyName,
1398
+ expandedName: propertyName,
1399
+ property,
1400
+ isCompound: false
1401
+ }];
1402
+ }
1403
+ const expanded = [];
1404
+ for (const field of registeredType.expand) {
1405
+ const expandedName = `${propertyName}${field.suffix}`;
1406
+ const expandedProperty = {
1407
+ type: "String",
1408
+ // Use String as placeholder, actual SQL type is in field.sql
1409
+ // Copy nullable from original property
1410
+ ...property.nullable !== void 0 ? { nullable: property.nullable } : {}
1411
+ };
1412
+ expanded.push({
1413
+ originalName: propertyName,
1414
+ expandedName,
1415
+ property: expandedProperty,
1416
+ isCompound: true,
1417
+ sourceType: typeName
1418
+ });
1419
+ }
1420
+ return expanded;
1421
+ }
1422
+ function expandSchemaProperties(schema, registry) {
1423
+ const expandedMap = /* @__PURE__ */ new Map();
1424
+ if (!schema.properties) {
1425
+ return expandedMap;
1426
+ }
1427
+ for (const [propName, property] of Object.entries(schema.properties)) {
1428
+ const expanded = expandProperty(propName, property, registry);
1429
+ expandedMap.set(propName, expanded);
1430
+ }
1431
+ return expandedMap;
1432
+ }
1433
+ function expandSchema(schema, registry) {
1434
+ if (!schema.properties || schema.kind === "enum") {
1435
+ return schema;
1436
+ }
1437
+ const expandedProperties = {};
1438
+ let hasExpansion = false;
1439
+ for (const [propName, property] of Object.entries(schema.properties)) {
1440
+ const expanded = expandProperty(propName, property, registry);
1441
+ const firstExpanded = expanded[0];
1442
+ if (expanded.length === 1 && firstExpanded && !firstExpanded.isCompound) {
1443
+ expandedProperties[propName] = property;
1444
+ } else {
1445
+ hasExpansion = true;
1446
+ for (const exp of expanded) {
1447
+ expandedProperties[exp.expandedName] = exp.property;
1448
+ }
1449
+ }
1450
+ }
1451
+ if (!hasExpansion) {
1452
+ return schema;
1453
+ }
1454
+ return {
1455
+ ...schema,
1456
+ properties: expandedProperties
1457
+ };
1458
+ }
1459
+ function expandSchemas(schemas, registry) {
1460
+ const expanded = {};
1461
+ for (const [name, schema] of Object.entries(schemas)) {
1462
+ expanded[name] = expandSchema(schema, registry);
1463
+ }
1464
+ return expanded;
1465
+ }
1466
+ function getTypeInfo(typeName, registry) {
1467
+ return registry.types.get(typeName);
1468
+ }
1469
+ function isCompoundType(typeName, registry) {
1470
+ const type = registry.types.get(typeName);
1471
+ return type?.compound === true;
1472
+ }
1473
+ function getCustomTypeNames(registry) {
1474
+ return Array.from(registry.types.keys());
1475
+ }
1476
+
1477
+ // src/api/omnify.ts
1478
+ var import_node_path = require("path");
1479
+
1480
+ // src/api/metadata.ts
1481
+ function isAssociation(prop) {
1482
+ return prop.type === "Association";
1483
+ }
1484
+ function getSchemaMetadata(schema) {
1485
+ const propertyNames = [];
1486
+ const associationNames = [];
1487
+ if (schema.properties) {
1488
+ for (const [name, prop] of Object.entries(schema.properties)) {
1489
+ if (isAssociation(prop)) {
1490
+ associationNames.push(name);
1491
+ } else {
1492
+ propertyNames.push(name);
1493
+ }
1494
+ }
1495
+ }
1496
+ const kind = schema.kind === "enum" ? "enum" : "entity";
1497
+ const result = {
1498
+ name: schema.name,
1499
+ kind,
1500
+ filePath: schema.filePath,
1501
+ propertyNames,
1502
+ associationNames,
1503
+ hasTimestamps: schema.options?.timestamps ?? false,
1504
+ hasSoftDelete: schema.options?.softDelete ?? false,
1505
+ primaryKeyType: schema.options?.primaryKeyType ?? "Int"
1506
+ };
1507
+ if (schema.displayName !== void 0) {
1508
+ result.displayName = schema.displayName;
1509
+ }
1510
+ if (schema.group !== void 0) {
1511
+ result.group = schema.group;
1512
+ }
1513
+ return result;
1514
+ }
1515
+ function getPropertyMetadata(name, property, registry) {
1516
+ if (isAssociation(property)) {
1517
+ return {
1518
+ name,
1519
+ type: "Association",
1520
+ nullable: false,
1521
+ unique: false,
1522
+ hasDefault: false,
1523
+ isPluginType: false
1524
+ };
1525
+ }
1526
+ const isPluginType = registry?.types.has(property.type) ?? false;
1527
+ const pluginType = registry?.types.get(property.type);
1528
+ const result = {
1529
+ name,
1530
+ type: property.type,
1531
+ nullable: property.nullable ?? false,
1532
+ unique: property.unique ?? false,
1533
+ hasDefault: "default" in property && property.default !== void 0,
1534
+ isPluginType
1535
+ };
1536
+ if ("default" in property && property.default !== void 0) {
1537
+ result.defaultValue = property.default;
1538
+ }
1539
+ if (pluginType?.pluginName !== void 0) {
1540
+ result.pluginName = pluginType.pluginName;
1541
+ }
1542
+ return result;
1543
+ }
1544
+ function getAssociationMetadata(name, association) {
1545
+ const result = {
1546
+ name,
1547
+ relation: association.relation,
1548
+ target: association.target
1549
+ };
1550
+ if (association.inversedBy !== void 0) {
1551
+ result.inversedBy = association.inversedBy;
1552
+ }
1553
+ if (association.mappedBy !== void 0) {
1554
+ result.mappedBy = association.mappedBy;
1555
+ }
1556
+ if (association.onDelete !== void 0) {
1557
+ result.onDelete = association.onDelete;
1558
+ }
1559
+ if (association.onUpdate !== void 0) {
1560
+ result.onUpdate = association.onUpdate;
1561
+ }
1562
+ return result;
1563
+ }
1564
+ function introspectSchema(schema, registry) {
1565
+ const metadata = getSchemaMetadata(schema);
1566
+ const properties = [];
1567
+ const associations = [];
1568
+ if (schema.properties) {
1569
+ for (const [name, prop] of Object.entries(schema.properties)) {
1570
+ if (isAssociation(prop)) {
1571
+ associations.push(getAssociationMetadata(name, prop));
1572
+ } else {
1573
+ properties.push(getPropertyMetadata(name, prop, registry));
1574
+ }
1575
+ }
1576
+ }
1577
+ return {
1578
+ metadata,
1579
+ properties,
1580
+ associations,
1581
+ schema
1582
+ };
1583
+ }
1584
+ function introspectSchemas(schemas, registry) {
1585
+ const result = /* @__PURE__ */ new Map();
1586
+ for (const [name, schema] of Object.entries(schemas)) {
1587
+ result.set(name, introspectSchema(schema, registry));
1588
+ }
1589
+ return result;
1590
+ }
1591
+ function getSchemaNames(schemas) {
1592
+ return Object.keys(schemas);
1593
+ }
1594
+ function getSchemasByKind(schemas, kind) {
1595
+ return Object.values(schemas).filter((schema) => {
1596
+ const schemaKind = schema.kind === "enum" ? "enum" : "entity";
1597
+ return schemaKind === kind;
1598
+ });
1599
+ }
1600
+ function getEntitySchemas(schemas) {
1601
+ return getSchemasByKind(schemas, "entity");
1602
+ }
1603
+ function getEnumSchemas(schemas) {
1604
+ return getSchemasByKind(schemas, "enum");
1605
+ }
1606
+ function getSchemasByGroup(schemas, group) {
1607
+ return Object.values(schemas).filter((schema) => schema.group === group);
1608
+ }
1609
+ function getGroups(schemas) {
1610
+ const groups = /* @__PURE__ */ new Set();
1611
+ for (const schema of Object.values(schemas)) {
1612
+ if (schema.group) {
1613
+ groups.add(schema.group);
1614
+ }
1615
+ }
1616
+ return Array.from(groups).sort();
1617
+ }
1618
+ function getSchemaAssociations(schema) {
1619
+ if (!schema.properties) return [];
1620
+ const associations = [];
1621
+ for (const prop of Object.values(schema.properties)) {
1622
+ if (isAssociation(prop)) {
1623
+ associations.push(prop);
1624
+ }
1625
+ }
1626
+ return associations;
1627
+ }
1628
+ function findReferencingSchemas(schemas, targetName) {
1629
+ const result = [];
1630
+ for (const schema of Object.values(schemas)) {
1631
+ const associations = getSchemaAssociations(schema);
1632
+ for (const association of associations) {
1633
+ if (association.target === targetName) {
1634
+ result.push(schema);
1635
+ break;
1636
+ }
1637
+ }
1638
+ }
1639
+ return result;
1640
+ }
1641
+ function findReferencedSchemas(schemas, sourceName) {
1642
+ const source = schemas[sourceName];
1643
+ if (!source) return [];
1644
+ const associations = getSchemaAssociations(source);
1645
+ const targetNames = new Set(associations.map((a) => a.target));
1646
+ return Object.values(schemas).filter((s) => targetNames.has(s.name));
1647
+ }
1648
+ function getRelationshipGraph(schemas) {
1649
+ const graph = /* @__PURE__ */ new Map();
1650
+ for (const schema of Object.values(schemas)) {
1651
+ const targets = [];
1652
+ const associations = getSchemaAssociations(schema);
1653
+ for (const association of associations) {
1654
+ if (!targets.includes(association.target)) {
1655
+ targets.push(association.target);
1656
+ }
1657
+ }
1658
+ graph.set(schema.name, targets);
1659
+ }
1660
+ return graph;
1661
+ }
1662
+ function hasCircularReferences(schemas) {
1663
+ const graph = getRelationshipGraph(schemas);
1664
+ const visited = /* @__PURE__ */ new Set();
1665
+ const recursionStack = /* @__PURE__ */ new Set();
1666
+ function hasCycle(node) {
1667
+ if (recursionStack.has(node)) return true;
1668
+ if (visited.has(node)) return false;
1669
+ visited.add(node);
1670
+ recursionStack.add(node);
1671
+ const neighbors = graph.get(node) ?? [];
1672
+ for (const neighbor of neighbors) {
1673
+ if (hasCycle(neighbor)) return true;
1674
+ }
1675
+ recursionStack.delete(node);
1676
+ return false;
1677
+ }
1678
+ for (const schemaName of graph.keys()) {
1679
+ if (hasCycle(schemaName)) return true;
1680
+ }
1681
+ return false;
1682
+ }
1683
+ function getTopologicalOrder(schemas) {
1684
+ const graph = getRelationshipGraph(schemas);
1685
+ const result = [];
1686
+ const visited = /* @__PURE__ */ new Set();
1687
+ function visit(node) {
1688
+ if (visited.has(node)) return;
1689
+ visited.add(node);
1690
+ const neighbors = graph.get(node) ?? [];
1691
+ for (const neighbor of neighbors) {
1692
+ visit(neighbor);
1693
+ }
1694
+ result.push(node);
1695
+ }
1696
+ for (const schemaName of graph.keys()) {
1697
+ visit(schemaName);
1698
+ }
1699
+ return result.reverse();
1700
+ }
1701
+
1702
+ // src/api/omnify.ts
1703
+ var nullLogger2 = {
1704
+ debug: () => {
1705
+ },
1706
+ info: () => {
1707
+ },
1708
+ warn: () => {
1709
+ },
1710
+ error: () => {
1711
+ }
1712
+ };
1713
+ var consoleLogger2 = {
1714
+ debug: (msg, ...args) => console.debug(`[omnify] ${msg}`, ...args),
1715
+ info: (msg, ...args) => console.info(`[omnify] ${msg}`, ...args),
1716
+ warn: (msg, ...args) => console.warn(`[omnify] ${msg}`, ...args),
1717
+ error: (msg, ...args) => console.error(`[omnify] ${msg}`, ...args)
1718
+ };
1719
+ var Omnify = class {
1720
+ options;
1721
+ logger;
1722
+ pluginManager;
1723
+ schemas = null;
1724
+ loaded = false;
1725
+ constructor(options) {
1726
+ this.options = {
1727
+ ...options,
1728
+ schemaDir: (0, import_node_path.resolve)(options.schemaDir)
1729
+ };
1730
+ this.logger = options.logger ?? (options.verbose ? consoleLogger2 : nullLogger2);
1731
+ this.pluginManager = createPluginManager({ logger: this.logger });
1732
+ }
1733
+ /**
1734
+ * Registers plugins with the plugin manager.
1735
+ */
1736
+ async registerPlugins(plugins) {
1737
+ for (const plugin of plugins) {
1738
+ this.logger.debug(`Registering plugin: ${plugin.name}`);
1739
+ const result = await this.pluginManager.register(plugin);
1740
+ if (!result.success) {
1741
+ throw new Error(`Failed to register plugin ${plugin.name}: ${result.error}`);
1742
+ }
1743
+ if (result.warnings.length > 0) {
1744
+ for (const warning of result.warnings) {
1745
+ this.logger.warn(warning);
1746
+ }
1747
+ }
1748
+ }
1749
+ }
1750
+ /**
1751
+ * Loads and validates schemas from the configured directory.
1752
+ */
1753
+ async load() {
1754
+ this.logger.info(`Loading schemas from: ${this.options.schemaDir}`);
1755
+ if (this.options.plugins?.length) {
1756
+ await this.registerPlugins(this.options.plugins);
1757
+ }
1758
+ const errors = [];
1759
+ const warnings = [];
1760
+ try {
1761
+ const schemas = await loadSchemas(this.options.schemaDir, {
1762
+ recursive: true
1763
+ });
1764
+ this.logger.debug(`Loaded ${Object.keys(schemas).length} schemas`);
1765
+ const customTypeNames = Array.from(this.pluginManager.getRegistry().types.keys());
1766
+ const validationResult = validateSchemas(schemas, {
1767
+ customTypes: customTypeNames
1768
+ });
1769
+ for (const error of validationResult.errors) {
1770
+ const schemaError = {
1771
+ file: error.file ?? "unknown",
1772
+ message: error.message
1773
+ };
1774
+ if (error.line !== void 0) {
1775
+ schemaError.line = error.line;
1776
+ }
1777
+ if (error.suggestion !== void 0) {
1778
+ schemaError.suggestion = error.suggestion;
1779
+ }
1780
+ errors.push(schemaError);
1781
+ }
1782
+ for (const warning of validationResult.warnings) {
1783
+ warnings.push({
1784
+ file: warning.file ?? "unknown",
1785
+ message: warning.message
1786
+ });
1787
+ }
1788
+ if (validationResult.valid) {
1789
+ this.schemas = schemas;
1790
+ this.loaded = true;
1791
+ }
1792
+ return {
1793
+ success: validationResult.valid,
1794
+ schemas,
1795
+ errors,
1796
+ warnings
1797
+ };
1798
+ } catch (error) {
1799
+ if (error instanceof OmnifyError) {
1800
+ const schemaError = {
1801
+ file: error.file ?? "unknown",
1802
+ message: error.message
1803
+ };
1804
+ if (error.line !== void 0) {
1805
+ schemaError.line = error.line;
1806
+ }
1807
+ if (error.suggestion !== void 0) {
1808
+ schemaError.suggestion = error.suggestion;
1809
+ }
1810
+ errors.push(schemaError);
1811
+ } else {
1812
+ errors.push({
1813
+ file: "unknown",
1814
+ message: error instanceof Error ? error.message : String(error)
1815
+ });
1816
+ }
1817
+ return {
1818
+ success: false,
1819
+ schemas: {},
1820
+ errors,
1821
+ warnings
1822
+ };
1823
+ }
1824
+ }
1825
+ /**
1826
+ * Gets loaded schemas. Throws if not loaded.
1827
+ */
1828
+ getSchemas() {
1829
+ if (!this.loaded || !this.schemas) {
1830
+ throw new Error("Schemas not loaded. Call load() first.");
1831
+ }
1832
+ return this.schemas;
1833
+ }
1834
+ /**
1835
+ * Gets a single schema by name.
1836
+ */
1837
+ getSchema(name) {
1838
+ const schemas = this.getSchemas();
1839
+ const schema = schemas[name];
1840
+ if (!schema) return void 0;
1841
+ return introspectSchema(schema, this.pluginManager.getRegistry());
1842
+ }
1843
+ /**
1844
+ * Gets all schema names.
1845
+ */
1846
+ getSchemaNames() {
1847
+ return getSchemaNames(this.getSchemas());
1848
+ }
1849
+ /**
1850
+ * Gets entity schemas (non-enum).
1851
+ */
1852
+ getEntitySchemas() {
1853
+ const schemas = getEntitySchemas(this.getSchemas());
1854
+ return schemas.map(
1855
+ (s) => introspectSchema(s, this.pluginManager.getRegistry())
1856
+ );
1857
+ }
1858
+ /**
1859
+ * Gets enum schemas.
1860
+ */
1861
+ getEnumSchemas() {
1862
+ const schemas = getEnumSchemas(this.getSchemas());
1863
+ return schemas.map(
1864
+ (s) => introspectSchema(s, this.pluginManager.getRegistry())
1865
+ );
1866
+ }
1867
+ /**
1868
+ * Gets schemas by group.
1869
+ */
1870
+ getSchemasByGroup(group) {
1871
+ const schemas = getSchemasByGroup(this.getSchemas(), group);
1872
+ return schemas.map(
1873
+ (s) => introspectSchema(s, this.pluginManager.getRegistry())
1874
+ );
1875
+ }
1876
+ /**
1877
+ * Gets all unique group names.
1878
+ */
1879
+ getGroups() {
1880
+ return getGroups(this.getSchemas());
1881
+ }
1882
+ /**
1883
+ * Introspects a specific schema.
1884
+ */
1885
+ introspect(name) {
1886
+ return this.getSchema(name);
1887
+ }
1888
+ /**
1889
+ * Introspects all schemas.
1890
+ */
1891
+ introspectAll() {
1892
+ return introspectSchemas(this.getSchemas(), this.pluginManager.getRegistry());
1893
+ }
1894
+ /**
1895
+ * Finds schemas that reference a target schema.
1896
+ */
1897
+ findReferencingSchemas(targetName) {
1898
+ const schemas = findReferencingSchemas(this.getSchemas(), targetName);
1899
+ return schemas.map(
1900
+ (s) => introspectSchema(s, this.pluginManager.getRegistry())
1901
+ );
1902
+ }
1903
+ /**
1904
+ * Finds schemas referenced by a source schema.
1905
+ */
1906
+ findReferencedSchemas(sourceName) {
1907
+ const schemas = findReferencedSchemas(this.getSchemas(), sourceName);
1908
+ return schemas.map(
1909
+ (s) => introspectSchema(s, this.pluginManager.getRegistry())
1910
+ );
1911
+ }
1912
+ /**
1913
+ * Checks if schemas have circular references.
1914
+ */
1915
+ hasCircularReferences() {
1916
+ return hasCircularReferences(this.getSchemas());
1917
+ }
1918
+ /**
1919
+ * Gets topological order of schemas (dependencies first).
1920
+ */
1921
+ getTopologicalOrder() {
1922
+ return getTopologicalOrder(this.getSchemas());
1923
+ }
1924
+ /**
1925
+ * Gets the plugin registry.
1926
+ */
1927
+ getPluginRegistry() {
1928
+ return this.pluginManager.getRegistry();
1929
+ }
1930
+ /**
1931
+ * Checks if a type is registered (from plugin).
1932
+ */
1933
+ hasType(typeName) {
1934
+ return this.pluginManager.hasType(typeName);
1935
+ }
1936
+ /**
1937
+ * Gets custom type names from all registered plugins.
1938
+ */
1939
+ getCustomTypeNames() {
1940
+ return Array.from(this.pluginManager.getRegistry().types.keys());
1941
+ }
1942
+ };
1943
+ function createOmnify(options) {
1944
+ return new Omnify(options);
1945
+ }
1946
+ // Annotate the CommonJS export names for ESM import in node:
1947
+ 0 && (module.exports = {
1948
+ Omnify,
1949
+ OmnifyError,
1950
+ PluginManager,
1951
+ atlasError,
1952
+ atlasNotFoundError,
1953
+ circularReferenceError,
1954
+ configError,
1955
+ configNotFoundError,
1956
+ createOmnify,
1957
+ createPluginManager,
1958
+ duplicateSchemaError,
1959
+ err,
1960
+ expandProperty,
1961
+ expandSchema,
1962
+ expandSchemaProperties,
1963
+ expandSchemas,
1964
+ fileNameToSchemaName,
1965
+ findReferencedSchemas,
1966
+ findReferencingSchemas,
1967
+ formatError,
1968
+ formatErrorPlain,
1969
+ formatErrorSummary,
1970
+ generationError,
1971
+ getAssociationMetadata,
1972
+ getCustomTypeNames,
1973
+ getEntitySchemas,
1974
+ getEnumSchemas,
1975
+ getExitCode,
1976
+ getGroups,
1977
+ getPropertyMetadata,
1978
+ getRelationshipGraph,
1979
+ getSchemaMetadata,
1980
+ getSchemaNames,
1981
+ getSchemasByGroup,
1982
+ getSchemasByKind,
1983
+ getTopologicalOrder,
1984
+ getTypeInfo,
1985
+ hasCircularReferences,
1986
+ internalError,
1987
+ introspectSchema,
1988
+ introspectSchemas,
1989
+ invalidAssociationTargetError,
1990
+ invalidConfigError,
1991
+ invalidPropertyTypeError,
1992
+ isCompoundType,
1993
+ jsonSyntaxError,
1994
+ loadSchema,
1995
+ loadSchemas,
1996
+ missingConfigFieldError,
1997
+ missingFieldError,
1998
+ notImplementedError,
1999
+ ok,
2000
+ outputWriteError,
2001
+ parseJsonSchema,
2002
+ parseYamlSchema,
2003
+ pluginError,
2004
+ pluginNotFoundError,
2005
+ pluginTypeConflictError,
2006
+ schemaNotFoundError,
2007
+ schemaParseError,
2008
+ validateAssociations,
2009
+ validateEnumSchema,
2010
+ validateOptions,
2011
+ validateProperties,
2012
+ validatePropertyType,
2013
+ validateSchema,
2014
+ validateSchemas,
2015
+ validationError,
2016
+ yamlSyntaxError
2017
+ });
2018
+ //# sourceMappingURL=index.cjs.map