@maykonpaulo/maestro-core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1382,6 +1382,47 @@ declare function loadDeclarativeConfigFromString(content: string, options: LoadD
1382
1382
  /** Reads, parses and validates a declarative config from a file path. Format is detected from the extension unless overridden. */
1383
1383
  declare function loadDeclarativeConfigFromFile(filePath: string, options?: LoadDeclarativeConfigFromFileOptions): Promise<DeclarativeFileConfig>;
1384
1384
 
1385
+ interface DeclarativeGeneratorOptions {
1386
+ /** Adds one minimal list/detail consumer per entity, derived from visible fields. Default: false. */
1387
+ includeConsumers?: boolean;
1388
+ /** Includes fields flagged as internal (hidden in metadata, or hidden: true in schema). Default: true. */
1389
+ includeInternalFields?: boolean;
1390
+ /** Sorts entities alphabetically by id and fields alphabetically by name for deterministic output. Default: true. */
1391
+ sort?: boolean;
1392
+ }
1393
+ /** Metadata-shaped input. Structurally compatible with `MaestroMetadata`, so it can be passed directly. */
1394
+ interface DeclarativeGeneratorMetadataInput {
1395
+ entities: EntityMetadata[];
1396
+ relations?: RelationMetadata[];
1397
+ operations?: OperationMetadata[];
1398
+ }
1399
+ /** Schema-shaped input, mirroring `MaestroConfig.entities` / `MaestroConfig.relations`. */
1400
+ interface DeclarativeGeneratorSchemaInput {
1401
+ entities: EntitySchema[];
1402
+ relations?: RelationSchema[];
1403
+ }
1404
+ /** Generates a `DeclarativeFileConfig` from already-built `EntityMetadata[]` (+ optional relations/operations). */
1405
+ declare function generateDeclarativeConfigFromMetadata(input: DeclarativeGeneratorMetadataInput, options?: DeclarativeGeneratorOptions): DeclarativeFileConfig;
1406
+ /** Generates a `DeclarativeFileConfig` from raw `EntitySchema[]` (+ optional relations), before metadata normalization. */
1407
+ declare function generateDeclarativeConfigFromSchema(input: DeclarativeGeneratorSchemaInput, options?: DeclarativeGeneratorOptions): DeclarativeFileConfig;
1408
+
1409
+ interface YamlSerializer {
1410
+ stringify(value: unknown): string;
1411
+ }
1412
+
1413
+ type DeclarativeSerializationFormat = 'yaml' | 'json';
1414
+ interface SerializeDeclarativeConfigOptions {
1415
+ format: DeclarativeSerializationFormat;
1416
+ /** Required for `format: 'yaml'`. The core has no YAML runtime dependency — pass a serializer (e.g. `{ stringify: YAML.stringify }` from the `yaml` package). */
1417
+ yamlSerializer?: YamlSerializer;
1418
+ }
1419
+ /** Serializes a declarative config to formatted, stable JSON. */
1420
+ declare function serializeDeclarativeConfigToJson(config: DeclarativeFileConfig): string;
1421
+ /** Serializes a declarative config to YAML using an injected serializer (the core has no bundled YAML dependency). */
1422
+ declare function serializeDeclarativeConfigToYaml(config: DeclarativeFileConfig, yamlSerializer: YamlSerializer): string;
1423
+ /** Serializes a declarative config to the requested textual format. */
1424
+ declare function serializeDeclarativeConfig(config: DeclarativeFileConfig, options: SerializeDeclarativeConfigOptions): string;
1425
+
1385
1426
  declare const GOVERNANCE_EVENT_TYPES: {
1386
1427
  readonly OPERATION_EXECUTED: "governance.operation.executed";
1387
1428
  readonly AUTHORIZATION_DENIED: "governance.authorization.denied";
@@ -1455,4 +1496,4 @@ declare class DefaultGovernanceApi implements GovernanceApi {
1455
1496
  getPolicyViolations(filter?: PolicyViolationFilter): Promise<PolicyViolation[]>;
1456
1497
  }
1457
1498
 
1458
- export { type Actor, type ActorType, type AuditEvent, type AuditFilter, type AuditLevel, type AuditRecordedPayload, AuditRecorder, type AuditRepository, type AuditTimeline, type AuthorizationContext, type AuthorizationDecision, type AuthorizationDeniedPayload, type AuthorizationProvider, type AuthorizationResult, type CompileDeclarationsOptions, type ConfigProvider, type ConfirmationApproval, type ConfirmationApprovedPayload, type ConfirmationDeclaration, ConfirmationEngine, type ConfirmationRejectedPayload, type ConfirmationRepository, type ConfirmationRequest, type ConfirmationRequestedPayload, type ConfirmationStatus, ConsoleLogger, ConsoleStructuredLogger, type ConsumerActionsConfig, type ConsumerDeclaration, type ConsumerDetailConfig, type ConsumerFormConfig, type ConsumerFormsConfig, type ConsumerListConfig, type ConsumerProjectionFields, type ConsumerProjectionOperations, type ContextAction, type ContextActionCondition, type ContextActionStyle, ContextualAuthorizationEngine, type CorrelationContext, type CorrelationId, type CreateMaestroFromIntrospectionOptions, CsvExportProvider, type CursorPagination, DEFAULT_CAPABILITIES, type DatasourceDeleteContext, type DatasourceFindContext, type DatasourceProvider, type DatasourceQueryContext, DatasourceRegistry, type DatasourceUpdateContext, type DatasourceWriteContext, type DeclarativeCompilationResult, type DeclarativeConfig, type DeclarativeFileConfig, type DeclarativeFileFormat, DefaultGovernanceApi, type DiffChange, type DiffChangeKind, DiffEngine, type DiffEngineOptions, type DiffSummary, type DomainEvent, type EntityCapabilities, type EntityDeclaration, type EntityDiffChange, type EntityDiffChangeKind, type EntityExportConfig, type EntityIntrospectionSchema, type EntityLabelConfig, type EntityMetadata, type EntitySchema, type EntitySourceConfig, type EnumOption, type EnumOptionDeclaration, ErrorCode, type EventBus, type EventHandler, type ExportConfig, type ExportFormat, type ExportOptions, type ExportProvider, type ExportResult, type FeatureFlag, type FeatureFlagProvider, type FieldDeclaration, type FieldDetailConfig, type FieldDiffChange, type FieldDiffChangeKind, type FieldFormConfig, type FieldIntrospectionSchema, type FieldListConfig, type FieldMetadata, type FieldSchema, type FieldSchemaDetailConfig, type FieldSchemaEnumOption, type FieldSchemaFormConfig, type FieldSchemaListConfig, type FieldType, type FileSystemReader, type FilterDescriptor, type FilterOperator, GOVERNANCE_EVENT_TYPES, type GeneratedConfig, type GovernanceApi, type GovernanceEventBus, type GovernanceEventType, type ImpactLevel, InMemoryAuditRepository, InMemoryConfigProvider, InMemoryConfirmationRepository, InMemoryDatasourceProvider, InMemoryEventBus, InMemoryFeatureFlagProvider, InMemoryGovernanceEventBus, InMemoryPolicyProvider, InMemorySnapshotRepository, type IndexIntrospectionSchema, type IntrospectionDiff, type IntrospectionProvider, type IntrospectionReport, type IntrospectionReportChange, type IntrospectionReportStats, type IntrospectionResult, IntrospectionRuntime, type IntrospectionRuntimeResult, type IntrospectionRuntimeRunOptions, type IntrospectionSnapshot, type ListResult, type LoadDeclarativeConfigFromFileOptions, type LoadDeclarativeConfigFromStringOptions, type LoadedConfig, type LogEntry, type LogLevel, type Logger, type MaestroActorResolver, type MaestroConfig, MaestroEngine, MaestroError, type MaestroFileLoaderOptions, type MaestroHttpHandler, type MaestroHttpHandlers, type MaestroHttpOptions, type MaestroHttpRequest, type MaestroHttpResponse, type MaestroMetadata, type MaestroRequestContext, type MergeIntrospectionOptions, type MergeStrategy, type Metadata, MetadataEngine, MetadataRiskClassifier, type MetadataValue, type OffsetPagination, type OperationContext, type OperationDeclaration, type OperationDef, type OperationExecutedPayload, type OperationLogStatus, type OperationMetadata, OperationRegistry, type OperationResult, type OperationScope, type OperationalRisk, type PagePagination, type PaginationInput, type Permission, type PolicyContext, type PolicyDecision, PolicyEngine, type PolicyEvaluationResult, type PolicyProvider, type PolicyRule, type PolicyRuleResult, type PolicyTriggeredPayload, type PolicyViolation, type PolicyViolationFilter, type QueryInput, RbacEngine, type RbacPolicy, type RecordAuditInput, type RelationDeclaration, type RelationDiffChange, type RelationDiffChangeKind, type RelationDisplayConfig, type RelationEndpoint, type RelationIntrospectionSchema, type RelationMetadata, type RelationSchema, type RelationType, ReportGenerator, type RequestConfirmationInput, type ResolvedConsumerProjection, type ResourceRef, type RiskClassificationInput, type RiskClassifier, type Role, type SchemaValidationError, type SchemaValidationResult, type SearchConfig, type SearchInput, type SnapshotRepository, type SoftDeleteConfig, type SortDescriptor, type SortDirection, type StructuredLogEntry, type StructuredLogger, type YamlParser, compileDeclarations, createMaestro, createMaestroFromIntrospection, createMaestroHttpHandlers, detectDisplayField, generateAllConfigs, generateCorrelationId, generateEntityConfig, generateRelationConfig, humanizeFieldName, inferFieldType, isSearchCandidate, isSoftDeleteCandidate, isTimestampField, loadDeclarativeConfigFromFile, loadDeclarativeConfigFromString, loadMaestroConfig, mergeIntrospectionWithOverrides, parseQueryInput, resolveConsumerProjections, tableNameToEntityId, tableNameToLabel, validateConsumerDeclaration, validateEntityDeclaration, validateMaestroConfig };
1499
+ export { type Actor, type ActorType, type AuditEvent, type AuditFilter, type AuditLevel, type AuditRecordedPayload, AuditRecorder, type AuditRepository, type AuditTimeline, type AuthorizationContext, type AuthorizationDecision, type AuthorizationDeniedPayload, type AuthorizationProvider, type AuthorizationResult, type CompileDeclarationsOptions, type ConfigProvider, type ConfirmationApproval, type ConfirmationApprovedPayload, type ConfirmationDeclaration, ConfirmationEngine, type ConfirmationRejectedPayload, type ConfirmationRepository, type ConfirmationRequest, type ConfirmationRequestedPayload, type ConfirmationStatus, ConsoleLogger, ConsoleStructuredLogger, type ConsumerActionsConfig, type ConsumerDeclaration, type ConsumerDetailConfig, type ConsumerFormConfig, type ConsumerFormsConfig, type ConsumerListConfig, type ConsumerProjectionFields, type ConsumerProjectionOperations, type ContextAction, type ContextActionCondition, type ContextActionStyle, ContextualAuthorizationEngine, type CorrelationContext, type CorrelationId, type CreateMaestroFromIntrospectionOptions, CsvExportProvider, type CursorPagination, DEFAULT_CAPABILITIES, type DatasourceDeleteContext, type DatasourceFindContext, type DatasourceProvider, type DatasourceQueryContext, DatasourceRegistry, type DatasourceUpdateContext, type DatasourceWriteContext, type DeclarativeCompilationResult, type DeclarativeConfig, type DeclarativeFileConfig, type DeclarativeFileFormat, type DeclarativeGeneratorMetadataInput, type DeclarativeGeneratorOptions, type DeclarativeGeneratorSchemaInput, type DeclarativeSerializationFormat, DefaultGovernanceApi, type DiffChange, type DiffChangeKind, DiffEngine, type DiffEngineOptions, type DiffSummary, type DomainEvent, type EntityCapabilities, type EntityDeclaration, type EntityDiffChange, type EntityDiffChangeKind, type EntityExportConfig, type EntityIntrospectionSchema, type EntityLabelConfig, type EntityMetadata, type EntitySchema, type EntitySourceConfig, type EnumOption, type EnumOptionDeclaration, ErrorCode, type EventBus, type EventHandler, type ExportConfig, type ExportFormat, type ExportOptions, type ExportProvider, type ExportResult, type FeatureFlag, type FeatureFlagProvider, type FieldDeclaration, type FieldDetailConfig, type FieldDiffChange, type FieldDiffChangeKind, type FieldFormConfig, type FieldIntrospectionSchema, type FieldListConfig, type FieldMetadata, type FieldSchema, type FieldSchemaDetailConfig, type FieldSchemaEnumOption, type FieldSchemaFormConfig, type FieldSchemaListConfig, type FieldType, type FileSystemReader, type FilterDescriptor, type FilterOperator, GOVERNANCE_EVENT_TYPES, type GeneratedConfig, type GovernanceApi, type GovernanceEventBus, type GovernanceEventType, type ImpactLevel, InMemoryAuditRepository, InMemoryConfigProvider, InMemoryConfirmationRepository, InMemoryDatasourceProvider, InMemoryEventBus, InMemoryFeatureFlagProvider, InMemoryGovernanceEventBus, InMemoryPolicyProvider, InMemorySnapshotRepository, type IndexIntrospectionSchema, type IntrospectionDiff, type IntrospectionProvider, type IntrospectionReport, type IntrospectionReportChange, type IntrospectionReportStats, type IntrospectionResult, IntrospectionRuntime, type IntrospectionRuntimeResult, type IntrospectionRuntimeRunOptions, type IntrospectionSnapshot, type ListResult, type LoadDeclarativeConfigFromFileOptions, type LoadDeclarativeConfigFromStringOptions, type LoadedConfig, type LogEntry, type LogLevel, type Logger, type MaestroActorResolver, type MaestroConfig, MaestroEngine, MaestroError, type MaestroFileLoaderOptions, type MaestroHttpHandler, type MaestroHttpHandlers, type MaestroHttpOptions, type MaestroHttpRequest, type MaestroHttpResponse, type MaestroMetadata, type MaestroRequestContext, type MergeIntrospectionOptions, type MergeStrategy, type Metadata, MetadataEngine, MetadataRiskClassifier, type MetadataValue, type OffsetPagination, type OperationContext, type OperationDeclaration, type OperationDef, type OperationExecutedPayload, type OperationLogStatus, type OperationMetadata, OperationRegistry, type OperationResult, type OperationScope, type OperationalRisk, type PagePagination, type PaginationInput, type Permission, type PolicyContext, type PolicyDecision, PolicyEngine, type PolicyEvaluationResult, type PolicyProvider, type PolicyRule, type PolicyRuleResult, type PolicyTriggeredPayload, type PolicyViolation, type PolicyViolationFilter, type QueryInput, RbacEngine, type RbacPolicy, type RecordAuditInput, type RelationDeclaration, type RelationDiffChange, type RelationDiffChangeKind, type RelationDisplayConfig, type RelationEndpoint, type RelationIntrospectionSchema, type RelationMetadata, type RelationSchema, type RelationType, ReportGenerator, type RequestConfirmationInput, type ResolvedConsumerProjection, type ResourceRef, type RiskClassificationInput, type RiskClassifier, type Role, type SchemaValidationError, type SchemaValidationResult, type SearchConfig, type SearchInput, type SerializeDeclarativeConfigOptions, type SnapshotRepository, type SoftDeleteConfig, type SortDescriptor, type SortDirection, type StructuredLogEntry, type StructuredLogger, type YamlParser, type YamlSerializer, compileDeclarations, createMaestro, createMaestroFromIntrospection, createMaestroHttpHandlers, detectDisplayField, generateAllConfigs, generateCorrelationId, generateDeclarativeConfigFromMetadata, generateDeclarativeConfigFromSchema, generateEntityConfig, generateRelationConfig, humanizeFieldName, inferFieldType, isSearchCandidate, isSoftDeleteCandidate, isTimestampField, loadDeclarativeConfigFromFile, loadDeclarativeConfigFromString, loadMaestroConfig, mergeIntrospectionWithOverrides, parseQueryInput, resolveConsumerProjections, serializeDeclarativeConfig, serializeDeclarativeConfigToJson, serializeDeclarativeConfigToYaml, tableNameToEntityId, tableNameToLabel, validateConsumerDeclaration, validateEntityDeclaration, validateMaestroConfig };
package/dist/index.js CHANGED
@@ -3411,6 +3411,189 @@ async function loadDeclarativeConfigFromFile(filePath, options = {}) {
3411
3411
  return loadDeclarativeConfigFromString(content, { format, yamlParser: options.yamlParser, source: filePath });
3412
3412
  }
3413
3413
 
3414
+ // src/declarative/generator/DeclarativeConfigGenerator.ts
3415
+ function sortByName(items) {
3416
+ return [...items].sort((a, b) => a.name.localeCompare(b.name));
3417
+ }
3418
+ function capabilitiesOverride(capabilities) {
3419
+ const overrides = {};
3420
+ let hasOverride = false;
3421
+ for (const key of Object.keys(DEFAULT_CAPABILITIES)) {
3422
+ if (capabilities[key] !== DEFAULT_CAPABILITIES[key]) {
3423
+ overrides[key] = capabilities[key];
3424
+ hasOverride = true;
3425
+ }
3426
+ }
3427
+ return hasOverride ? overrides : void 0;
3428
+ }
3429
+ function relationToDeclaration(rel) {
3430
+ return {
3431
+ id: rel.id,
3432
+ type: rel.type,
3433
+ fromField: rel.from.field,
3434
+ toEntity: rel.to.entity,
3435
+ toField: rel.to.field,
3436
+ label: rel.label,
3437
+ display: rel.display ? { tab: rel.display.tab, label: rel.display.label } : void 0
3438
+ };
3439
+ }
3440
+ function fieldMetadataToDeclaration(field, primaryKey) {
3441
+ const decl = { type: field.type };
3442
+ if (field.label) decl.label = field.label;
3443
+ if (field.required) decl.required = true;
3444
+ if (field.readonly) decl.readonly = true;
3445
+ if (field.name === primaryKey) decl.primary = true;
3446
+ if (field.sensitive) decl.sensitive = true;
3447
+ if (field.hidden) decl.visible = false;
3448
+ if (field.searchable) decl.searchable = true;
3449
+ if (field.sortable) decl.sortable = true;
3450
+ if (field.filterable) decl.filterable = true;
3451
+ if (field.exportable) decl.exportable = true;
3452
+ if (field.description) decl.description = field.description;
3453
+ if (field.enumOptions) decl.enumOptions = field.enumOptions;
3454
+ if (field.relationEntity) decl.relationEntity = field.relationEntity;
3455
+ return decl;
3456
+ }
3457
+ function fieldSchemaToDeclaration(field, primaryKey) {
3458
+ const decl = { type: field.type };
3459
+ if (field.label) decl.label = field.label;
3460
+ if (field.required) decl.required = true;
3461
+ if (field.readonly) decl.readonly = true;
3462
+ if (primaryKey && field.name === primaryKey) decl.primary = true;
3463
+ if (field.sensitive) decl.sensitive = true;
3464
+ if (field.hidden) decl.visible = false;
3465
+ if (field.searchable) decl.searchable = true;
3466
+ if (field.sortable) decl.sortable = true;
3467
+ if (field.filterable) decl.filterable = true;
3468
+ if (field.exportable) decl.exportable = true;
3469
+ if (field.description) decl.description = field.description;
3470
+ if (field.enumOptions) decl.enumOptions = field.enumOptions;
3471
+ if (field.relationEntity) decl.relationEntity = field.relationEntity;
3472
+ return decl;
3473
+ }
3474
+ function operationMetadataToDeclaration(op, entityId) {
3475
+ const key = op.id.startsWith(`${entityId}.`) ? op.id.slice(entityId.length + 1) : op.id;
3476
+ const declaration = { label: op.label };
3477
+ if (op.description) declaration.description = op.description;
3478
+ if (op.scope) declaration.scope = op.scope;
3479
+ if (op.requiresConfirmation) declaration.confirmation = { required: true };
3480
+ if (op.requiredPermission) declaration.permission = op.requiredPermission;
3481
+ return { key, declaration };
3482
+ }
3483
+ function entityMetadataToDeclaration(entity, relations, operations, options) {
3484
+ const sourceFields = options.includeInternalFields ? entity.fields : entity.fields.filter((f) => !f.hidden);
3485
+ const orderedFields = options.sort ? sortByName(sourceFields) : sourceFields;
3486
+ const fields = {};
3487
+ for (const field of orderedFields) {
3488
+ fields[field.name] = fieldMetadataToDeclaration(field, entity.primaryKey);
3489
+ }
3490
+ const orderedRelations = options.sort ? [...relations].sort((a, b) => a.id.localeCompare(b.id)) : relations;
3491
+ const orderedOperations = options.sort ? [...operations].sort((a, b) => a.id.localeCompare(b.id)) : operations;
3492
+ const operationsRecord = {};
3493
+ for (const op of orderedOperations) {
3494
+ const { key, declaration: declaration2 } = operationMetadataToDeclaration(op, entity.id);
3495
+ operationsRecord[key] = declaration2;
3496
+ }
3497
+ const declaration = {
3498
+ entity: entity.id,
3499
+ label: entity.label.singular,
3500
+ pluralLabel: entity.label.plural,
3501
+ fields
3502
+ };
3503
+ if (entity.description) declaration.description = entity.description;
3504
+ const capabilities = capabilitiesOverride(entity.capabilities);
3505
+ if (capabilities) declaration.capabilities = capabilities;
3506
+ if (orderedOperations.length > 0) declaration.operations = operationsRecord;
3507
+ if (orderedRelations.length > 0) {
3508
+ declaration.relationships = orderedRelations.map(relationToDeclaration);
3509
+ }
3510
+ return declaration;
3511
+ }
3512
+ function entitySchemaToDeclaration(entity, relations, options) {
3513
+ const sourceFields = options.includeInternalFields ? entity.fields : entity.fields.filter((f) => !f.hidden);
3514
+ const orderedFields = options.sort ? sortByName(sourceFields) : sourceFields;
3515
+ const fields = {};
3516
+ for (const field of orderedFields) {
3517
+ fields[field.name] = fieldSchemaToDeclaration(field, entity.source.primaryKey);
3518
+ }
3519
+ const orderedRelations = options.sort ? [...relations].sort((a, b) => a.id.localeCompare(b.id)) : relations;
3520
+ const declaration = {
3521
+ entity: entity.id,
3522
+ label: entity.label.singular,
3523
+ pluralLabel: entity.label.plural,
3524
+ fields
3525
+ };
3526
+ if (entity.description) declaration.description = entity.description;
3527
+ if (entity.capabilities) declaration.capabilities = entity.capabilities;
3528
+ if (orderedRelations.length > 0) {
3529
+ declaration.relationships = orderedRelations.map(relationToDeclaration);
3530
+ }
3531
+ return declaration;
3532
+ }
3533
+ function generateDefaultConsumerDeclaration(entity) {
3534
+ const visibleFieldNames = Object.entries(entity.fields).filter(([, field]) => field.visible !== false).map(([name]) => name);
3535
+ return {
3536
+ consumer: entity.entity,
3537
+ entity: entity.entity,
3538
+ list: { fields: visibleFieldNames },
3539
+ detail: { fields: visibleFieldNames }
3540
+ };
3541
+ }
3542
+ function generateDeclarativeConfigFromMetadata(input, options = {}) {
3543
+ const resolved = {
3544
+ includeInternalFields: options.includeInternalFields ?? true,
3545
+ sort: options.sort ?? true
3546
+ };
3547
+ const orderedEntities = resolved.sort ? [...input.entities].sort((a, b) => a.id.localeCompare(b.id)) : input.entities;
3548
+ const entities = orderedEntities.map(
3549
+ (entity) => entityMetadataToDeclaration(
3550
+ entity,
3551
+ (input.relations ?? []).filter((rel) => rel.from.entity === entity.id),
3552
+ (input.operations ?? []).filter((op) => op.entity === entity.id),
3553
+ resolved
3554
+ )
3555
+ );
3556
+ const consumers = options.includeConsumers ? entities.map(generateDefaultConsumerDeclaration) : void 0;
3557
+ return consumers ? { entities, consumers } : { entities };
3558
+ }
3559
+ function generateDeclarativeConfigFromSchema(input, options = {}) {
3560
+ const resolved = {
3561
+ includeInternalFields: options.includeInternalFields ?? true,
3562
+ sort: options.sort ?? true
3563
+ };
3564
+ const orderedEntities = resolved.sort ? [...input.entities].sort((a, b) => a.id.localeCompare(b.id)) : input.entities;
3565
+ const entities = orderedEntities.map(
3566
+ (entity) => entitySchemaToDeclaration(
3567
+ entity,
3568
+ (input.relations ?? []).filter((rel) => rel.from.entity === entity.id),
3569
+ resolved
3570
+ )
3571
+ );
3572
+ const consumers = options.includeConsumers ? entities.map(generateDefaultConsumerDeclaration) : void 0;
3573
+ return consumers ? { entities, consumers } : { entities };
3574
+ }
3575
+
3576
+ // src/declarative/generator/DeclarativeConfigSerializer.ts
3577
+ function serializeDeclarativeConfigToJson(config) {
3578
+ return `${JSON.stringify(config, null, 2)}
3579
+ `;
3580
+ }
3581
+ function serializeDeclarativeConfigToYaml(config, yamlSerializer) {
3582
+ return yamlSerializer.stringify(config);
3583
+ }
3584
+ function serializeDeclarativeConfig(config, options) {
3585
+ if (options.format === "json") {
3586
+ return serializeDeclarativeConfigToJson(config);
3587
+ }
3588
+ if (!options.yamlSerializer) {
3589
+ throw new MaestroError(
3590
+ "CONFIGURATION_ERROR" /* CONFIGURATION_ERROR */,
3591
+ 'Cannot serialize declarative config to YAML: a "yamlSerializer" must be provided. The core has no bundled YAML dependency \u2014 install a YAML library (e.g. "yaml") and pass { yamlSerializer: { stringify: YAML.stringify } }.'
3592
+ );
3593
+ }
3594
+ return serializeDeclarativeConfigToYaml(config, options.yamlSerializer);
3595
+ }
3596
+
3414
3597
  // src/governance/GovernanceEventType.ts
3415
3598
  var GOVERNANCE_EVENT_TYPES = {
3416
3599
  OPERATION_EXECUTED: "governance.operation.executed",
@@ -3514,6 +3697,8 @@ export {
3514
3697
  detectDisplayField,
3515
3698
  generateAllConfigs,
3516
3699
  generateCorrelationId,
3700
+ generateDeclarativeConfigFromMetadata,
3701
+ generateDeclarativeConfigFromSchema,
3517
3702
  generateEntityConfig,
3518
3703
  generateRelationConfig,
3519
3704
  humanizeFieldName,
@@ -3527,6 +3712,9 @@ export {
3527
3712
  mergeIntrospectionWithOverrides,
3528
3713
  parseQueryInput,
3529
3714
  resolveConsumerProjections,
3715
+ serializeDeclarativeConfig,
3716
+ serializeDeclarativeConfigToJson,
3717
+ serializeDeclarativeConfigToYaml,
3530
3718
  tableNameToEntityId,
3531
3719
  tableNameToLabel,
3532
3720
  validateConsumerDeclaration,